Class LoggingHelper
- Namespace
- StockSharp.Logging
- Assembly
- StockSharp.Logging.dll
Extension class for ILogSource.
public static class LoggingHelper
- Inheritance
-
LoggingHelper
- Inherited Members
Fields
OnlyError
The filter that only accepts messages of Error type.
public static readonly Func<LogMessage, bool> OnlyError
Field Value
OnlyWarning
The filter that only accepts messages of Warning type.
public static readonly Func<LogMessage, bool> OnlyWarning
Field Value
Methods
AddDebugLog(ILogReceiver, string, params object[])
To record a debug message to the log.
public static void AddDebugLog(this ILogReceiver receiver, string message, params object[] args)
Parameters
receiver
ILogReceiverLogs receiver.
message
stringText message.
args
object[]Text message settings. Used if a message is the format string. For details, see Format(string, params object[]).
AddErrorLog(ILogReceiver, Exception)
To record an error to the log.
public static void AddErrorLog(this ILogReceiver receiver, Exception exception)
Parameters
receiver
ILogReceiverLogs receiver.
exception
ExceptionError details.
AddErrorLog(ILogReceiver, Exception, string)
To record an error to the log.
public static void AddErrorLog(this ILogReceiver receiver, Exception exception, string format)
Parameters
receiver
ILogReceiverLogs receiver.
exception
ExceptionError details.
format
stringA format string.
AddErrorLog(ILogReceiver, Func<string>)
To record an error to the log.
public static void AddErrorLog(this ILogReceiver receiver, Func<string> getMessage)
Parameters
receiver
ILogReceiverLogs receiver.
getMessage
Func<string>The function returns the text for Message.
AddErrorLog(ILogReceiver, string, params object[])
To record an error to the log.
public static void AddErrorLog(this ILogReceiver receiver, string message, params object[] args)
Parameters
receiver
ILogReceiverLogs receiver.
message
stringText message.
args
object[]Text message settings. Used if a message is the format string. For details, see Format(string, params object[]).
AddInfoLog(ILogReceiver, Func<string>)
To record a message to the log.
public static void AddInfoLog(this ILogReceiver receiver, Func<string> getMessage)
Parameters
receiver
ILogReceiverLogs receiver.
getMessage
Func<string>The function returns the text for Message.
AddInfoLog(ILogReceiver, string, params object[])
To record a message to the log.
public static void AddInfoLog(this ILogReceiver receiver, string message, params object[] args)
Parameters
receiver
ILogReceiverLogs receiver.
message
stringText message.
args
object[]Text message settings. Used if a message is the format string. For details, see Format(string, params object[]).
AddLog(ILogReceiver, LogLevels, Func<string>)
To record a message to the log.
public static void AddLog(this ILogReceiver receiver, LogLevels level, Func<string> getMessage)
Parameters
receiver
ILogReceiverLogs receiver.
level
LogLevelsThe level of the log message.
getMessage
Func<string>The function returns the text for Message.
AddVerboseLog(ILogReceiver, string, params object[])
To record a verbose message to the log.
public static void AddVerboseLog(this ILogReceiver receiver, string message, params object[] args)
Parameters
receiver
ILogReceiverLogs receiver.
message
stringText message.
args
object[]Text message settings. Used if a message is the format string. For details, see Format(string, params object[]).
AddWarningLog(ILogReceiver, Func<string>)
To record a warning to the log.
public static void AddWarningLog(this ILogReceiver receiver, Func<string> getMessage)
Parameters
receiver
ILogReceiverLogs receiver.
getMessage
Func<string>The function returns the text for Message.
AddWarningLog(ILogReceiver, string, params object[])
To record a warning to the log.
public static void AddWarningLog(this ILogReceiver receiver, string message, params object[] args)
Parameters
receiver
ILogReceiverLogs receiver.
message
stringText message.
args
object[]Text message settings. Used if a message is the format string. For details, see Format(string, params object[]).
DoWithLog(Action)
Wrap the specified action in try/catch clause with logging.
public static void DoWithLog(this Action action)
Parameters
action
ActionThe action.
DoWithLog<T>(Func<IDictionary<T, Exception>>)
Wrap the specified action in try/catch clause with logging.
public static void DoWithLog<T>(Func<IDictionary<T, Exception>> action)
Parameters
action
Func<IDictionary<T, Exception>>The action.
Type Parameters
T
The type of returned result.
DoWithLog<T>(Func<T>)
Wrap the specified action in try/catch clause with logging.
public static T DoWithLog<T>(this Func<T> action)
Parameters
action
Func<T>The action.
Returns
- T
The resulting value.
Type Parameters
T
The type of returned result.
Filter(IEnumerable<LogMessage>, ICollection<Func<LogMessage, bool>>)
Filter messages.
public static IEnumerable<LogMessage> Filter(this IEnumerable<LogMessage> messages, ICollection<Func<LogMessage, bool>> filters)
Parameters
messages
IEnumerable<LogMessage>Incoming messages.
filters
ICollection<Func<LogMessage, bool>>Messages filters that specify which messages should be handled.
Returns
- IEnumerable<LogMessage>
Filtered collection.
GetLogLevel(ILogSource)
public static LogLevels GetLogLevel(this ILogSource source)
Parameters
source
ILogSourceThe log source.
Returns
- LogLevels
Logging level.
LogError(Exception, string)
To record an error to the Application.
public static void LogError(this Exception error, string format = null)
Parameters
SafeAdd<T1, T2>(IEnumerable, Func<T1, T2>)
Wrap the specified action in try/catch clause with logging.
public static T2[] SafeAdd<T1, T2>(this IEnumerable from, Func<T1, T2> func)
Parameters
from
IEnumerableSource values
func
Func<T1, T2>Converter.
Returns
- T2[]
Result.
Type Parameters
T1
The type of source values.
T2
The type of returned result.
WriteMessage(ILogListener, LogMessage)
Write message.
public static void WriteMessage(this ILogListener listener, LogMessage message)
Parameters
listener
ILogListenermessage
LogMessage