- addLog
void addLog(Verbosity verbosity, Param params)
Undocumented in source. Be warned that the author may not have intended to support it.
- error
void error(Param params)
Undocumented in source. Be warned that the author may not have intended to support it.
- info
void info(Param params)
Undocumented in source. Be warned that the author may not have intended to support it.
- isError
bool isError()
Undocumented in source. Be warned that the author may not have intended to support it.
- isInfo
bool isInfo()
Undocumented in source. Be warned that the author may not have intended to support it.
- isTrace
bool isTrace()
Undocumented in source. Be warned that the author may not have intended to support it.
- isWarn
bool isWarn()
Undocumented in source. Be warned that the author may not have intended to support it.
- logLevel
int logLevel()
Undocumented in source. Be warned that the author may not have intended to support it.
- opIndex
string opIndex(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
- opIndexAssign
void opIndexAssign(Value value, Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
- setError
void setError()
Undocumented in source. Be warned that the author may not have intended to support it.
- setInfo
void setInfo()
Undocumented in source. Be warned that the author may not have intended to support it.
- setLogLevel
void setLogLevel(LogLevel logLevel)
Undocumented in source. Be warned that the author may not have intended to support it.
- setLogLevel
void setLogLevel(int logLevel)
Undocumented in source. Be warned that the author may not have intended to support it.
- setTrace
void setTrace()
Undocumented in source. Be warned that the author may not have intended to support it.
- setWarn
void setWarn()
Undocumented in source. Be warned that the author may not have intended to support it.
- timer
auto timer(string timerName)
Undocumented in source. Be warned that the author may not have intended to support it.
- trace
void trace(Param params)
Undocumented in source. Be warned that the author may not have intended to support it.
- warn
void warn(Param params)
Undocumented in source. Be warned that the author may not have intended to support it.
The primary interface into the logging system. Logger is templatized based on:
Serializer - formats the output and passes it to writer TimeProvider - what source of time to use
By default the Serializer is JSON and the TimeProvider uses the standard Clock in std.datetime. In this case simply pass a delegate callback that takes the serialized string data and does whatever you want with it. The constructor will take care of initializing the JSON serializer with your provided callback.
If you want to use a different serializer simple pass it in instead to the properly templatized struct:
auto mySerializer = MySerializer(); auto logger = Logger!(MySerializer)(mySerializer);
The only constraint is that your serializer implements opCall which takes a ref to the EventContext object. Thus it could be a function, delegate, struct or class.
If you want to provide your own source of time (for testing, or some external time provider) you just call the constructor with your TimeProvider which again must implement opCall and returns a UnixTime:
auto myTimeProvider = () { return UnixTime(0); }; auto logger = Logger!(MySerializer, typeof(myTimeProvider))(xxx, myTimeProvider);
As you log against the log defer instance it will accumulate the logs into its internal buffer. Once the object goes out of scope the logs are passed to the serializer which handles formatting and writing out the logs.