File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ class DateTimeFileWriter
6868 * name_format:
6969 * (string) The log file name format; parsed with `date()`.
7070 *
71+ * extension:
72+ * (string) The file extention to append to the filename`.
73+ *
7174 * message_format:
7275 * (string) The log message format; available tokens are...
7376 * %label% Replaced with the log message level (e.g. FATAL, ERROR, WARN).
@@ -83,6 +86,7 @@ public function __construct($settings = array())
8386 $ this ->settings = array_merge (array (
8487 'path ' => './logs ' ,
8588 'name_format ' => 'Y-m-d ' ,
89+ 'extension ' => 'log ' ,
8690 'message_format ' => '%label% - %date% - %message% '
8791 ), $ settings );
8892
@@ -129,7 +133,12 @@ public function write($object, $level)
129133
130134 //Open resource handle to log file
131135 if (!$ this ->resource ) {
132- $ this ->resource = fopen ($ this ->settings ['path ' ] . DIRECTORY_SEPARATOR . date ($ this ->settings ['name_format ' ]), 'a ' );
136+ $ filename = date ($ this ->settings ['name_format ' ]);
137+ if (! empty ($ this ->settings ['extension ' ])) {
138+ $ filename .= '. ' . $ this ->settings ['extension ' ];
139+ }
140+
141+ $ this ->resource = fopen ($ this ->settings ['path ' ] . DIRECTORY_SEPARATOR . $ filename , 'a ' );
133142 }
134143
135144 //Output to resource
You can’t perform that action at this time.
0 commit comments