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 |
---|---|
System.Boolean | 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 |
System.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 |
System.String | format | the format string |
System.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 |
System.String | format | the format string |
System.Object | param1 | the first parameter |
System.Object | param2 | the second parameter |
Log(LogLevel, String, 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 |
System.String | format | the format string |
System.Object[] | allParams | the parameters |