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
receiverILogReceiverLogs receiver.
messagestringText message.
argsobject[]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
receiverILogReceiverLogs receiver.
exceptionExceptionError details.
AddErrorLog(ILogReceiver, Exception, string)
To record an error to the log.
public static void AddErrorLog(this ILogReceiver receiver, Exception exception, string format)
Parameters
receiverILogReceiverLogs receiver.
exceptionExceptionError details.
formatstringA format string.
AddErrorLog(ILogReceiver, Func<string>)
To record an error to the log.
public static void AddErrorLog(this ILogReceiver receiver, Func<string> getMessage)
Parameters
receiverILogReceiverLogs receiver.
getMessageFunc<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
receiverILogReceiverLogs receiver.
messagestringText message.
argsobject[]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
receiverILogReceiverLogs receiver.
getMessageFunc<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
receiverILogReceiverLogs receiver.
messagestringText message.
argsobject[]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
receiverILogReceiverLogs receiver.
levelLogLevelsThe level of the log message.
getMessageFunc<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
receiverILogReceiverLogs receiver.
messagestringText message.
argsobject[]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
receiverILogReceiverLogs receiver.
getMessageFunc<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
receiverILogReceiverLogs receiver.
messagestringText message.
argsobject[]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
actionActionThe 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
actionFunc<IDictionary<T, Exception>>The action.
Type Parameters
TThe 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
actionFunc<T>The action.
Returns
- T
The resulting value.
Type Parameters
TThe 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
messagesIEnumerable<LogMessage>Incoming messages.
filtersICollection<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
sourceILogSourceThe 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
fromIEnumerableSource values
funcFunc<T1, T2>Converter.
Returns
- T2[]
Result.
Type Parameters
T1The type of source values.
T2The type of returned result.
WriteMessage(ILogListener, LogMessage)
Write message.
public static void WriteMessage(this ILogListener listener, LogMessage message)
Parameters
listenerILogListenermessageLogMessage