Skip to content

Commit

Permalink
改进命令行日志
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jan 11, 2019
1 parent 2853d76 commit df2e645
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions library/think/log/driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ public function save(array $log = [], $append = false)
*/
protected function getMasterLogFile()
{
$cli = PHP_SAPI == 'cli' ? '_cli' : '';
if ($this->config['single']) {
$name = is_string($this->config['single']) ? $this->config['single'] : 'single';

$destination = $this->config['path'] . $name . '.log';
$name = is_string($this->config['single']) ? $this->config['single'] : 'single';
$destination = $this->config['path'] . $name . $cli . '.log';
} else {
$cli = PHP_SAPI == 'cli' ? '_cli' : '';

if ($this->config['max_files']) {
$filename = date('Ymd') . $cli . '.log';
$files = glob($this->config['path'] . '*.log');
Expand Down Expand Up @@ -125,15 +123,13 @@ protected function getApartLevelFile($path, $type)

if ($this->config['single']) {
$name = is_string($this->config['single']) ? $this->config['single'] : 'single';

$name .= '_' . $type;
} elseif ($this->config['max_files']) {
$name = date('Ymd') . '_' . $type . $cli;
$name = date('Ymd');
} else {
$name = date('d') . '_' . $type . $cli;
$name = date('d');
}

return $path . DIRECTORY_SEPARATOR . $name . '.log';
return $path . DIRECTORY_SEPARATOR . $name . '_' . $type . $cli . '.log';
}

/**
Expand Down

0 comments on commit df2e645

Please sign in to comment.