aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/logger
diff options
context:
space:
mode:
Diffstat (limited to 'libphobos/src/std/logger')
-rw-r--r--libphobos/src/std/logger/core.d4
-rw-r--r--libphobos/src/std/logger/filelogger.d16
-rw-r--r--libphobos/src/std/logger/package.d2
3 files changed, 16 insertions, 6 deletions
diff --git a/libphobos/src/std/logger/core.d b/libphobos/src/std/logger/core.d
index cc938d4..1e879fd 100644
--- a/libphobos/src/std/logger/core.d
+++ b/libphobos/src/std/logger/core.d
@@ -1433,7 +1433,7 @@ logger by the user, the default logger's log level is LogLevel.info.
Example:
-------------
-sharedLog = new FileLogger(yourFile);
+sharedLog = new shared FileLogger(yourFile);
-------------
The example sets a new `FileLogger` as new `sharedLog`.
@@ -1450,7 +1450,7 @@ writing `sharedLog`.
The default `Logger` is thread-safe.
-------------
if (sharedLog !is myLogger)
- sharedLog = new myLogger;
+ sharedLog = new shared myLogger;
-------------
*/
@property shared(Logger) sharedLog() @safe
diff --git a/libphobos/src/std/logger/filelogger.d b/libphobos/src/std/logger/filelogger.d
index c662ca7..5ba167c 100644
--- a/libphobos/src/std/logger/filelogger.d
+++ b/libphobos/src/std/logger/filelogger.d
@@ -37,7 +37,7 @@ class FileLogger : Logger
auto l3 = new FileLogger("logFile", LogLevel.fatal, CreateFolder.yes);
-------------
*/
- this(const string fn, const LogLevel lv = LogLevel.all) @safe
+ this(this This)(const string fn, const LogLevel lv = LogLevel.all)
{
this(fn, lv, CreateFolder.yes);
}
@@ -63,7 +63,7 @@ class FileLogger : Logger
auto l2 = new FileLogger(file, LogLevel.fatal);
-------------
*/
- this(const string fn, const LogLevel lv, CreateFolder createFileNameFolder) @safe
+ this(this This)(const string fn, const LogLevel lv, CreateFolder createFileNameFolder)
{
import std.file : exists, mkdirRecurse;
import std.path : dirName;
@@ -80,7 +80,8 @@ class FileLogger : Logger
" created in '", d,"' could not be created."));
}
- this.file_.open(this.filename, "a");
+ // Cast away `shared` when the constructor is inferred shared.
+ () @trusted { (cast() this.file_).open(this.filename, "a"); }();
}
/** A constructor for the `FileLogger` Logger that takes a reference to
@@ -270,3 +271,12 @@ class FileLogger : Logger
assert(tl !is null);
stdThreadLocalLog.logLevel = LogLevel.all;
}
+
+@safe unittest
+{
+ // we don't need to actually run the code, only make sure
+ // it compiles
+ static _() {
+ auto l = new shared FileLogger("");
+ }
+}
diff --git a/libphobos/src/std/logger/package.d b/libphobos/src/std/logger/package.d
index 14a4394..215ca20 100644
--- a/libphobos/src/std/logger/package.d
+++ b/libphobos/src/std/logger/package.d
@@ -64,7 +64,7 @@ using the property called `sharedLog`. This property is 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");
+sharedLog = new shared FileLogger("New_Default_Log_File.log");
-------------
Additional `Logger` can be created by creating a new instance of the