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