Class Logger
A basic logger facade that delegates to an underlying output implementation.
Inherited Members
Namespace: LaunchDarkly.Logging
Assembly: LaunchDarkly.Logging.dll
Syntax
public sealed class Logger
Remarks
Code that generates log output will send it through this class. What happens to the output depends on the ILogAdapter that was used to create the Logger.
The logger has output methods for each of the levels defined in LogLevel. Each can take either a simple string, or a format string with variable parameters in the syntax used by Format(string, object). For efficiency (to avoid unnecessarily creating varargs arrays), each method has four overloads: one simple string, format with one parameter, format with two parameters, and format with an arbitrary number of parameters.
Methods
Debug(object)
Writes a message at Debug level.
Declaration
public void Debug(object message)
Parameters
Type | Name | Description |
---|---|---|
object | message | the message; if null, nothing is logged |
Debug(string, object)
Writes a message at Debug level with one parameter.
Declaration
public void Debug(string format, object param)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string; if null, nothing is logged |
object | param | the parameter |
Debug(string, object, object)
Writes a message at Debug level with two parameters.
Declaration
public void Debug(string format, object param1, object param2)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string; if null, nothing is logged |
object | param1 | the first parameter |
object | param2 | the second parameter |
Debug(string, params object[])
Writes a message at Debug level with any number of parameters.
Declaration
public void Debug(string format, params object[] allParams)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string; if null, nothing is logged |
object[] | allParams | the parameters |
Error(object)
Writes a message at Error level.
Declaration
public void Error(object message)
Parameters
Type | Name | Description |
---|---|---|
object | message | the message |
Error(string, object, object)
Writes a message at Error level with two parameters.
Declaration
public void Error(string format, object param1, object param2)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object | param1 | the first parameter |
object | param2 | the second parameter |
Error(string, params object[])
Writes a message at Error level with any number of parameters.
Declaration
public void Error(string format, params object[] allParams)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object[] | allParams | the parameters |
Info(object)
Writes a message at Info level.
Declaration
public void Info(object message)
Parameters
Type | Name | Description |
---|---|---|
object | message | the message |
Info(string, object)
Writes a message at Info level with one parameter.
Declaration
public void Info(string format, object param)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object | param | the parameter |
Info(string, object, object)
Writes a message at Info level with two parameters.
Declaration
public void Info(string format, object param1, object param2)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object | param1 | the first parameter |
object | param2 | the second parameter |
Info(string, params object[])
Writes a message at Info level with any number of parameters.
Declaration
public void Info(string format, params object[] allParams)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object[] | allParams | the parameters |
IsEnabled(LogLevel)
Tests whether log output for a certain level is at least potentially visible.
Declaration
public bool IsEnabled(LogLevel level)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | a log level |
Returns
Type | Description |
---|---|
bool | true if this level is potentially visible |
Remarks
Generally, any desired level filtering should be set up in the initial logging
configuration, and code that generates log messages should simply call methods like
Info(object) without having to know whether that particular level
is enabled or is being filtered out. However, if some kind of log message is particularly
expensive to compute, you may call IsEnabled
; a false value means you can skip
trying to log any message at that level.
Another approach is to generate any computationally expensive output lazily, such as by using the methods in LogValues.
SubLogger(string)
Creates a logger instance derived from this instance.
Declaration
public Logger SubLogger(string nameSuffix)
Parameters
Type | Name | Description |
---|---|---|
string | nameSuffix | will be appended to the current logger's name, separated by a period, to create the new logger's name |
Returns
Type | Description |
---|---|
Logger | a new logger instance |
Warn(object)
Writes a message at Warn level.
Declaration
public void Warn(object message)
Parameters
Type | Name | Description |
---|---|---|
object | message | the message |
Warn(string, object)
Writes a message at Warn level with one parameter.
Declaration
public void Warn(string format, object param)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object | param | the parameter |
Warn(string, object, object)
Writes a message at Warn level with two parameters.
Declaration
public void Warn(string format, object param1, object param2)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object | param1 | the first parameter |
object | param2 | the second parameter |
Warn(string, params object[])
Writes a message at Warn level with any number of parameters.
Declaration
public void Warn(string format, params object[] allParams)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object[] | allParams | the parameters |
WithAdapter(ILogAdapter, string)
Creates a named logger instance using the specified adapter.
Declaration
public static Logger WithAdapter(ILogAdapter adapter, string name)
Parameters
Type | Name | Description |
---|---|---|
ILogAdapter | adapter | the ILogAdapter that defines the actual logging implementation |
string | name | the name for this logger |
Returns
Type | Description |
---|---|
Logger | a new logger instance |
Remarks
This method (or the equivalent shortcut adapter.Logger(name)
) is called by
library code to acquire a Logger
instance that it will write output to.
error(string, object)
Writes a message at Error level with one parameter.
Declaration
public void error(string format, object param)
Parameters
Type | Name | Description |
---|---|---|
string | format | the format string |
object | param | the parameter |