View source code
Display the source code in std/experimental/logger/core.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.experimental.logger.core.stdThreadLocalLog

This function returns a thread unique Logger, that by default propergates all data logged to it to the sharedLog.

Logger stdThreadLocalLog() @property @safe;

void stdThreadLocalLog (
  Logger logger
) @property @safe;

These properties can be used to set and get this Logger. Every modification to this Logger will only be visible in the thread the modification has been done from.

This Logger is called by the free standing log functions. This allows to create thread local redirections and still use the free standing log functions.

Example

Ditto

import std.experimental.logger.filelogger : FileLogger;
import std.file : deleteme, remove;
Logger l = stdThreadLocalLog;
stdThreadLocalLog = new FileLogger(deleteme ~ "-someFile.log");
scope(exit) remove(deleteme ~ "-someFile.log");

auto tempLog = stdThreadLocalLog;
stdThreadLocalLog = l;
destroy(tempLog);

Authors

License