Interface IChannel
The underlying implementation object used by some Logger instance.
Namespace: LaunchDarkly.Logging
Assembly: LaunchDarkly.Logging.dll
Syntax
public interface IChannel
Remarks
Applications or libraries that generate log output do not need to interact directly with IChannel; implementations of it are created by whatever ILogAdapter is being used.
The logger will send messages to this object, each with a LogLevel. If output is
known to be completely disabled for the specified level, the IChannel
method should
return immediately and do no other processing. Otherwise, for simple messages it should call
ToString()
on the message parameter. It can always assume that message
and
format
parameters are non-null.
The reason that format
/param
values are passed straight through from Logger
to IChannel
, instead of having Logger
do the string interpolation, is that an
IChannel implementation that is delegating to another logging framework may not
be able to know for sure whether a given log level is enabled (since filtering rules might be
configured elsewhere in that framework); providing the parameters separately lets the
implementation class decide whether or not to incur the overhead of string interpolation.
The reason that there are four overloads for Log()
is for efficiency, to avoid
allocating a params array in the common case of a message with fewer than three parameters.
Methods
IsEnabled(LogLevel)
Tests whether log output for a certain level is at least potentially visible.
Declaration
bool IsEnabled(LogLevel level)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level |
Returns
Type | Description |
---|---|
bool | true if this level is potentially visible |
Remarks
This is the underlying implementation of IsEnabled(LogLevel). The method should return true if the specified level is enabled in the sense that it will not be simply discarded by this IChannel. It should only return false if the IChannel will definitely discard that level.
Log(LogLevel, object)
Logs a simple message with no parameters.
Declaration
void Log(LogLevel level, object message)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | the log level |
object | message | the message |
Log(LogLevel, string, object)
Logs a message with a single parameter.
Declaration
void Log(LogLevel level, string format, object param)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | the log level |
string | format | the format string |
object | param | the parameter |
Log(LogLevel, string, object, object)
Logs a message with two parameters.
Declaration
void Log(LogLevel level, string format, object param1, object param2)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | the log level |
string | format | the format string |
object | param1 | the first parameter |
object | param2 | the second parameter |
Log(LogLevel, string, params object[])
Logs a message with any number of parameters.
Declaration
void Log(LogLevel level, string format, params object[] allParams)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | the log level |
string | format | the format string |
object[] | allParams | the parameters |