Skip to content

Commit e76bfe8

Browse files
fdreamfdream
authored andcommitted
record error's message
1 parent db35835 commit e76bfe8

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/FileLog.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
<?php
2-
class FileLog {
3-
public static function logThrowable(Throwable $e, string $dir, string $title = '') {
4-
if (! is_dir($dir))
5-
mkdir($dir);
6-
$s = sprintf('[%s] %s: ', date('Y-m-d H:i:s', time()), $title);
7-
$s .= str_replace([
8-
BASEDIR,
9-
"\n"
10-
], [
11-
'',
12-
'<=='
13-
], $e->getFile() . "({$e->getLine()}))\n{$e->getTraceAsString()}") . "\n";
14-
$fp = fopen($dir . date('Y-m-d') . '.log', 'a');
15-
fwrite($fp, $s);
16-
fclose($fp);
17-
}
1+
<?php
2+
class FileLog {
3+
public static function logThrowable(Throwable $e, string $dir, string $title = '') {
4+
if (! is_dir($dir))
5+
mkdir($dir);
6+
$s = sprintf('[%s] %s: ', date('Y-m-d H:i:s', time()), $title);
7+
$s .= str_replace([
8+
BASEDIR,
9+
"\n"
10+
], [
11+
'',
12+
'<=='
13+
], $e->getMessage() . ' ' . $e->getFile() . "({$e->getLine()}))\n{$e->getTraceAsString()}") . "\n";
14+
$fp = fopen($dir . date('Y-m-d') . '.log', 'a');
15+
fwrite($fp, $s);
16+
fclose($fp);
17+
}
1818
}

0 commit comments

Comments
 (0)