Bug 15517 – std.experimental.logger: using 'sharedLog' to change to file logging for default logger does not work

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2016-01-05T03:36:20Z
Last change time
2018-01-05T13:29:02Z
Assigned to
No Owner
Creator
varaccts

Comments

Comment #0 by varaccts — 2016-01-05T03:36:20Z
import std.experimental.logger; void main(string[] args) { sharedLog = new FileLogger("logfile.log"); log("Test log 1"); log("Test log 2"); log("Test log 3"); } $ ls -l logfile.log -rw-r--r-- 1 randomuser staff 0 Jan 4 19:19 logfile.log The above creates the 'logfile.log' file, but does not seem to redirect the default logs to the file -- at program exit, the 'logfile.log' is empty. From the documentation, this should've changed the default logger to logging to the file from logging to stderr. Referring to the 'sharedLog' works though -- it seems like this just creates a new logger and doesn't affect the default logger property?? import std.experimental.logger; void main(string[] args) { sharedLog = new FileLogger("logfile.log"); sharedLog.log("Test log 1"); sharedLog.log("Test log 2"); sharedLog.log("Test log 3"); } $ ls -l logfile.log -rw-r--r-- 1 randomuser staff 142 Jan 4 19:34 logfile.log As per the doc: From the doc: The default Logger will by default log to stderr and has a default LogLevel of LogLevel.all. The default Logger can be accessed by using the property called sharedLog. This property a reference to the current default Logger. This reference can be used to assign a new default Logger. sharedLog = new FileLogger("New_Default_Log_File.log");
Comment #1 by rburners — 2016-01-05T12:11:27Z
Comment #2 by github-bugzilla — 2017-05-29T19:26:56Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/27b6122d942e17edeb7db6aafd148f6ab88a1f19 fix Issue 15517 was already fixed but had no fixture https://github.com/dlang/phobos/commit/07e0293dbafdb9a9574509e3d5d12cda0603f690 Merge pull request #5371 from burner/issue15517 fix Issue 15517: std.experimental.logger: using 'sharedLog' to change to file logging for default logger does not work merged-on-behalf-of: Jack Stouffer <[email protected]>
Comment #3 by github-bugzilla — 2017-06-17T11:35:01Z
Comment #4 by github-bugzilla — 2018-01-05T13:29:02Z