Name | Summary |
---|---|
net.adamec.lib.common.core.config | |
net.adamec.lib.common.core.logging | |
net.adamec.lib.common.core.utils |
Name | Modifier | Kind | Summary |
---|---|---|---|
BaseDisposable | public abstract | Class | Helper class for implementation of System.IDisposable types |
CommonLogging | public static | Class | ILogger factory |
Configuration | public | Class | Singleton holding the application configuration (options) |
Configuration.ConfigurationBuilder | public | Class | Configuration builder providing the methods for adding the configuration items from individual sources |
LoggerExt | public | Class | Extended logger implementing ILogger |
ILogger | public abstract | Interface | Logger interface - wrapper around the NLog.ILogger with some additional methods |
Go to namespaces or types
Name | Modifier | Summary |
---|---|---|
Configuration | public | Singleton holding the application configuration (options) |
Configuration.ConfigurationBuilder | public | Configuration builder providing the methods for adding the configuration items from individual sources |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Sources: config\Configuration.cs
Singleton holding the application configuration (options)
public sealed class Configuration
Inheritance: object
This is the simple configuration container in case DI with more sophisticated containers is not used The configuration is stored as the key-value dictionary, supporting hierarchy using the dot separator and arrays.The arrays can contain values or another objects. Actually, mixed arrays of values and objects can be stored, but they are not supported for binding. For example section1.option1
means the option1 available in section1, section1.subSection2.option1
means the option1 available in section1.subSection2. section1.option1[0]
means, that the option1 is array of values or objects (sections) within the section1. For arrays, the keys are like OtherSection.SimpleArray[0]
or OtherSection.ComplexObjectArray[0].Name
Configuration class provides a singleton instance, however the key functionality is provided via static functions, so no need to touch the Instance at all. The items can be retrieved by key using the Get(string) and Get<TValueType>(string, Configuration.TValueType) methods. The first one returns null when the key is not found, the other one allow to define the default value to be returned, when the item is not found.
The inner class Configuration.ConfigurationBuilder provides the methods to build the configuration from JSON config files, commandline arguments, environment values and/or direct entries. The static method Builder() clears the configuration items and binding cache and creates a new instance of Configuration.ConfigurationBuilder allowing to build a configuration from scratch. The configuration is updated directly during the calls to builder methods, the existing items (keys) are updated, so it's possible to manage the priority of individual sources and the overrides if needed. The method Build() returns the configuration instance, breaking the fluent design of builder methods, however there is no other functionality within the method, so it's more the convention than need to use it at the end of configuration build.
Configuration binding it the way, how to access the configuration using the configuration objects instead of querying the individual items by key. When the method Bind<TOptionsContainer>(string, bool) is used, it creates a new instance of given type and tries to map the public properties with public setter to the keys (using the "dot notation") within the Configuration . It's possible to bind the object to to the root of the configuration to provide the whole configuration at once or bind it to the particular section to provide a configuration sub-tree. In general, the nested objects and both value and object arrays are supported. There are some rules when binding the arrays: The index must start with zero and must be in sequence (the first non-existing index stops the evaluation). The array should not mix the array or values and array of objects. The decision is made at the first item (index=0) whether it's value or object.
The implementation of binding treats the System.Boolean values the special way - if there is no value, but existing key, the value is converted to true. This is useful when the command line arguments are used like flags. For example having the argument -p:SkipStep1
and prefix -p:
, the binding a bool property SkipStep1
will set the value of the property to true
(doesn't change the configuration item itself). Of course, it's still possible to use the syntax -p:SkipStep1=true
or -p:SkipStep1=false
even in this case.
As the binding uses the reflection, it's quite expensive operation, so by default, the bound objects are cached (the cache key is the type of bound object, so binding the same type to different sections is not recommended ). It's possible to force the binding using the parameter of Bind<TOptionsContainer>(string, bool) method. In general, the recommended pattern is to Bind<TOptionsContainer>(string, bool) the configuration object after the configuration is built and then Retrieve<TOptionsContainer>() it from the cache when needed.
Name | Modifier | Summary |
---|---|---|
bindingsCache | private | Cache for bindings. Dictionary of type bound as a key and the bound object as value. |
instance | private static | Instance of the Configuration created when the singleton is first touched |
Name | Modifier | Summary |
---|---|---|
Instance | public static | Public Configuration instance |
Items | private | Configuration items stored as key-value pairs |
Name | Modifier | Summary |
---|---|---|
Configuration() | private static | Static constructor |
Configuration() | private | Private constructor used to build the singleton instance |
Name | Modifier | Summary |
---|---|---|
AddOrUpdateItem(string, object) | private | Add a new configuration item with given value or updates its value if the key already exists. |
Bind(Type, string) | private static | Creates a new object with given type and binds the configuration to its public properties where possible. |
Bind<TOptionsContainer>(string, bool) | public static | Binds the configuration to given TOptionsContainer type and returns the bound object of such type. The resulting configuration object is stored to the cache and can be later on retrieved using Retrieve<TOptionsContainer>() |
Builder() | public static | Clears the configuration items and binding cache and creates a new instance of Configuration.ConfigurationBuilder |
Get(string) | public static | Gets the configuration item by key |
Get<TValueType>(string, Configuration.TValueType) | public static | Gets the typed configuration item by key . Returns the default value, that can be provided or is default to given TValueType The function tries to convert the value to TValueType using System.Convert.ChangeType(System.Object,System.Type) if the conversion is not successful, the default is returned. |
GetSection(string) | private static | Gets the configuration sub-tree that belongs to given section. The keys returned are relative to given section! When the section is not provided, the whole configuration tree is returned. |
Retrieve<TOptionsContainer>() | public static | Retrieves the configuration object of given TOptionsContainer that has been bound and cached before. The new instance of TOptionsContainer is created when the type not found in cache |
TryConvertValue(Type, object, object) | private static | Tries to convert sourceValue to targetType . The converted values is returned in targetValue out parameter, the result of conversion is the function return value. |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Cache for bindings. Dictionary of type bound as a key and the bound object as value.
private readonly ConcurrentDictionary<System.Type,object> bindingsCache
Field value
Cache is used to prevent the "expensive" binding operation in case there is no need to refresh the bound configuration object
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Instance of the Configuration created when the singleton is first touched
private static readonly Configuration instance
Field value
Not using the auto-property to have better control, when the instance is created
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Public Configuration instance
public static Configuration Instance { get; }
Property value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Configuration items stored as key-value pairs
private ConcurrentDictionary<string,object> Items { get; }
Property value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Static constructor
private static Configuration()
Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Private constructor used to build the singleton instance
private Configuration()
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Add a new configuration item with given value or updates its value if the key already exists.
private void AddOrUpdateItem(string key, object value)
Method parameters
Return value- System.ArgumentException
- key is null or empty
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Creates a new object with given type and binds the configuration to its public properties where possible.
private static object Bind(Type type, string sectionName = null)
Method parameters
- System.Type type
- Type to bind the configuration to
- string sectionName
- Optional section to bind
- object
- The instance of type bound to the configuration
This method doesn't use the binding cache
- System.ArgumentNullException
- type is null
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Binds the configuration to given TOptionsContainer type and returns the bound object of such type. The resulting configuration object is stored to the cache and can be later on retrieved using Retrieve<TOptionsContainer>()
public static Configuration.TOptionsContainer Bind<TOptionsContainer>(string sectionName = null, bool allowCached = true) where TOptionsContainer: new()
Type parameters
- TOptionsContainer
- Type to bind the configuration to
- string sectionName
- Optional section to bind
- bool allowCached
- True if the cache of bindings can be used to retrieve existing binding with the same TOptionsContainer and sectionName
- net.adamec.lib.common.core.config.Configuration.TOptionsContainer
- The instance of TOptionsContainer bound to the configuration
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Clears the configuration items and binding cache and creates a new instance of Configuration.ConfigurationBuilder
public static Configuration.ConfigurationBuilder Builder()
Return value
- net.adamec.lib.common.core.config.Configuration.ConfigurationBuilder
- The instance of Configuration.ConfigurationBuilder
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Gets the configuration item by key
public static object Get(string key)
Method parameters
- string key
- Key of the configuration item
- object
- Retrieved configuration item value or null if not found (or the configuration item is null itself)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Gets the typed configuration item by key . Returns the default value, that can be provided or is default to given TValueType The function tries to convert the value to TValueType using System.Convert.ChangeType(System.Object,System.Type) if the conversion is not successful, the default is returned.
public static Configuration.TValueType Get<TValueType>(string key, Configuration.TValueType defaultValue = null)
Type parameters
- TValueType
- The type the value is to be retrieved in
- string key
- Key of the configuration item
- net.adamec.lib.common.core.config.Configuration.TValueType defaultValue
- Optional default value to be returned when the value can't be retrieved of converted
- net.adamec.lib.common.core.config.Configuration.TValueType
- Retrieved configuration item value or defaultValue when it can't be retrieved or converted
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Gets the configuration sub-tree that belongs to given section. The keys returned are relative to given section! When the section is not provided, the whole configuration tree is returned.
private static Dictionary<string,object> GetSection(string sectionName = null)
Method parameters
- string sectionName
- Optional name of the section.
- Dictionary<string,object>
- The configuration items that belong to the section with sectionName . The keys in returned dictionary are relative to given section!
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Retrieves the configuration object of given TOptionsContainer that has been bound and cached before. The new instance of TOptionsContainer is created when the type not found in cache
public static Configuration.TOptionsContainer Retrieve<TOptionsContainer>() where TOptionsContainer: new()
Type parameters
- TOptionsContainer
- Type of the configuration class to retrieve from cache
- net.adamec.lib.common.core.config.Configuration.TOptionsContainer
- The instance of TOptionsContainer bound to the configuration or a new instance if not found
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration
Sources: config\Configuration.cs
Tries to convert sourceValue to targetType . The converted values is returned in targetValue out parameter, the result of conversion is the function return value.
private static bool TryConvertValue(Type targetType, object sourceValue, out object targetValue)
Method parameters
- System.Type targetType
- Target (property) type
- object sourceValue
- Source value as stored in configuration item
- object targetValue
- sourceValue converted to targetType when the conversion succeeded (return value is true) or source value otherwise
- bool
- The result or conversion. If true, the targetValue can be set to property having targetType
The implementation treats the System.Boolean values the special way - if there is no value, but existing key, the value is converted to true.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Sources: config\Configuration.cs
Configuration builder providing the methods for adding the configuration items from individual sources
public class Configuration.ConfigurationBuilder
Inheritance: object
Name | Modifier | Summary |
---|---|---|
Add(string, object) | public | Add a new configuration item with given value or updates its value if the key already exists. |
AddCommandLineArguments(string[]) | public | Adds the command line arguments starting with prefixes into the Configuration . When a configuration item exists, the value is updated. |
AddEnvironmentVariables() | public | Adds all environment variables into the Configuration . When a configuration item exists, the value is updated. |
AddJsonFile(string, bool, bool) | public | Loads the configuration items from JSON file, keeping the hierarchy of JSON objects (and arrays) When a configuration item exists, the value is updated. |
Build() | public | Finishes the configuration building and returns the Instance |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration.ConfigurationBuilder
Sources: config\Configuration.cs
Add a new configuration item with given value or updates its value if the key already exists.
public Configuration.ConfigurationBuilder Add(string key, object value)
Method parameters
Return value- net.adamec.lib.common.core.config.Configuration.ConfigurationBuilder
- The current Configuration.ConfigurationBuilder
- System.ArgumentException
- key is null or empty
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration.ConfigurationBuilder
Sources: config\Configuration.cs
Adds the command line arguments starting with prefixes into the Configuration . When a configuration item exists, the value is updated.
public Configuration.ConfigurationBuilder AddCommandLineArguments(params string[] prefixes)
Method parameters
- string[] prefixes
- Optional list of prefixes marking the command line arguments to be the configuration items
- net.adamec.lib.common.core.config.Configuration.ConfigurationBuilder
- The current Configuration.ConfigurationBuilder
The command line arguments have the syntax key=value
(for example Key1=Option1
or prefixkey=value
(for example -p:Key1=Option1
where -p:
is the prefix). When the prefixes are not provided, all command line arguments are added to the configuration. When the prefixes are provided,the prefix is not a part of the key. The implementation of binding treats the System.Boolean values the special way - if there is no value, but existing key, the value is converted to true, allowing to use the parameters like flags. For example having the argument -p:SkipStep1
and prefix -p:
, the binding a bool property SkipStep1
will set the value of the property to true
(doesn't change the configuration item itself). Of course, it's still possible to use the syntax -p:SkipStep1=true
or -p:SkipStep1=false
even in this case.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration.ConfigurationBuilder
Sources: config\Configuration.cs
Adds all environment variables into the Configuration . When a configuration item exists, the value is updated.
public Configuration.ConfigurationBuilder AddEnvironmentVariables()
Return value
- net.adamec.lib.common.core.config.Configuration.ConfigurationBuilder
- The current Configuration.ConfigurationBuilder
The name of the environment variable is used as a key to the configuration item. Use the "dot notation" in variable names to support the configuration hierarchy.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration.ConfigurationBuilder
Sources: config\Configuration.cs
Loads the configuration items from JSON file, keeping the hierarchy of JSON objects (and arrays) When a configuration item exists, the value is updated.
public Configuration.ConfigurationBuilder AddJsonFile(string fileName, bool ignoreNullOrEmptyFileName = false, bool ignoreIfNotExist = false)
Method parameters
- string fileName
- Name of the JSON file with configuration
- bool ignoreNullOrEmptyFileName
- If true, the missing file name will not throw the exception and the method just "silently" ends.
- bool ignoreIfNotExist
- If true, the non existing file will not throw the exception and the method just "silently" ends.
- net.adamec.lib.common.core.config.Configuration.ConfigurationBuilder
- The current Configuration.ConfigurationBuilder
- System.ArgumentException
- fileName is null or empty and ignoreNullOrEmptyFileName is false
- System.ArgumentException
- fileName doesn't exist and ignoreIfNotExist is false
Go to namespaces or types
Namespace: net.adamec.lib.common.core.config
Assembly: net.adamec.lib.common.core
Type: Configuration.ConfigurationBuilder
Sources: config\Configuration.cs
Finishes the configuration building and returns the Instance
public Configuration Build()
Return value
Go to namespaces or types
Name | Modifier | Summary |
---|---|---|
CommonLogging | public static | ILogger factory |
LoggerExt | public | Extended logger implementing ILogger |
Name | Modifier | Summary |
---|---|---|
ILogger | public abstract | Logger interface - wrapper around the NLog.ILogger with some additional methods |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Sources: logging\CommonLogging.cs
ILogger factory
public static class CommonLogging
Inheritance: object
Name | Modifier | Summary |
---|---|---|
CreateLogger(string) | public static | Creates the logger with given categoryName |
CreateLogger(Type) | public static | Creates the logger for given type. The name of the logger will be System.Type.FullName |
CreateLogger<T>() | public static | Creates the logger for given type. The name of the logger will be System.Type.FullName |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: CommonLogging
Sources: logging\CommonLogging.cs
Creates the logger with given categoryName
public static ILogger CreateLogger(string categoryName)
Method parameters
- string categoryName
- Name of the logger
- net.adamec.lib.common.core.logging.ILogger
- Logger instance
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: CommonLogging
Sources: logging\CommonLogging.cs
Creates the logger for given type. The name of the logger will be System.Type.FullName
public static ILogger CreateLogger(Type type)
Method parameters
- System.Type type
- Type to create the logger for
- net.adamec.lib.common.core.logging.ILogger
- Logger instance
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: CommonLogging
Sources: logging\CommonLogging.cs
Creates the logger for given type. The name of the logger will be System.Type.FullName
public static ILogger CreateLogger<T>()
Type parameters
- T
- Type to create the logger for
- net.adamec.lib.common.core.logging.ILogger
- Logger instance
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Sources: logging\LoggerExt.CorrelationId.cs, logging\LoggerExt.cs, logging\LoggerExt.EventProperties.cs, logging\LoggerExt.ExceptionFilter.cs, logging\LoggerExt.ExceptionPassThrough.cs
Extended logger implementing ILogger
public class LoggerExt : Logger, ILogger
Inheritance: object -> NLog.Logger
Implements: net.adamec.lib.common.core.logging.ILogger, NLog.ILogger, NLog.ILoggerBase, NLog.ISuppress
Name | Modifier | Summary |
---|---|---|
CreateException<TException>(string, string, Exception) | private static | Writes the diagnostic message at the Fatal level. Creates and returns the exception of given type |
Debug(Dictionary<string,object>, string) | public | Writes the diagnostic message at the Debug level. |
DebugCorr(string, string) | public | Writes the diagnostic message at the Debug level with correlation ID. |
Error(Dictionary<string,object>, Exception, string) | public | Writes the diagnostic message at the Error level. |
Error(Dictionary<string,object>, string) | public | Writes the diagnostic message at the Error level. |
Error<TException>(string, Exception) | public | Writes the diagnostic message at the Error level. Creates and returns the exception of given type |
ErrorCorr(string, Exception, string) | public | Writes the diagnostic message at the Error level with correlation ID. |
ErrorCorr(string, string) | public | Writes the diagnostic message at the Error level with correlation ID. |
ErrorCorr<TException>(string, LoggerExt.TException, string) | public | Writes the diagnostic message at the Error level and returns the exception of given type |
ErrorCorr<TException>(string, string, Exception) | public | Writes the diagnostic message at the Error level with correlation ID. Creates and returns the exception of given type |
ErrorFltr<TException>(LoggerExt.TException, string, bool) | public | Writes the diagnostic message at the Error level and returns the exception of given type |
ErrorFltrCorr<TException>(string, LoggerExt.TException, string, bool) | public | Writes the diagnostic message at the Error level and returns the exception of given type |
ErrorPassThrough(Exception, string) | public | Writes the diagnostic message at the Error level and returns given exception |
Fatal(Dictionary<string,object>, Exception, string) | public | Writes the diagnostic message at the Fatal level. |
Fatal(Dictionary<string,object>, string) | public | Writes the diagnostic message at the Fatal level. |
Fatal<TException>(string, Exception) | public | Writes the diagnostic message at the Fatal level. Creates and returns the exception of given type |
FatalCorr(string, Exception, string) | public | Writes the diagnostic message at the Fatal level with correlation ID. |
FatalCorr(string, string) | public | Writes the diagnostic message at the Fatal level with correlation ID. |
FatalCorr<TException>(string, LoggerExt.TException, string) | public | Writes the diagnostic message at the Fatal level and returns the exception of given type |
FatalCorr<TException>(string, string, Exception) | public | Writes the diagnostic message at the Fatal level with correlation ID. Creates and returns the exception of given type |
FatalFltr<TException>(LoggerExt.TException, string, bool) | public | Writes the diagnostic message at the Fatal level and returns catchIt value. |
FatalFltrCorr<TException>(string, LoggerExt.TException, string, bool) | public | Writes the diagnostic message at the Fatal level and returns catchIt value. |
FatalPassThrough(Exception, string) | public | Writes the diagnostic message at the Fatal level and returns given exception > |
Info(Dictionary<string,object>, string) | public | Writes the diagnostic message at the Info level. |
InfoCorr(string, string) | public | Writes the diagnostic message at the Info level with correlation ID. |
LogIt(LogLevel, Dictionary<string,object>, string, Exception, string) | private | Writes the item (message with optional event properties and exception) into the log |
LogIt(LogLevel, string, Exception, string) | private | Writes the item (message with optional exception) into the log |
LogIt(LogLevel, string, string, Exception, string) | private | Writes the item (message with optional exception) with correlation Id into the log |
Trace(Dictionary<string,object>, string) | public | Writes the diagnostic message at the Trace level. |
TraceCorr(string, string) | public | Writes the diagnostic message at the Trace level with correlation ID |
Warn(Dictionary<string,object>, Exception, string) | public | Writes the diagnostic message at the Warn level. |
Warn(Dictionary<string,object>, string) | public | Writes the diagnostic message at the Warn level. |
WarnCorr(string, Exception, string) | public | Writes the diagnostic message at the Warn level with correlation ID. |
WarnCorr(string, string) | public | Writes the diagnostic message at the Warn level with correlation ID. |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.cs
Writes the diagnostic message at the Fatal
level. Creates and returns the exception of given type
private static LoggerExt.TException CreateException<TException>(string message, out string stackTrace, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string message
- Log message.
- string stackTrace
- Stack trace to be logged in
StackTrace
event property - System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Debug
level.
public void Debug(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Debug
level with correlation ID.
public void DebugCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueImplements: ILogger.DebugCorr(string, string)Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Error
level.
public void Error(Dictionary<string,object> eventProperties, Exception exception, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Error
level.
public void Error(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.ExceptionPassThrough.cs
Writes the diagnostic message at the Error
level. Creates and returns the exception of given type
public LoggerExt.TException Error<TException>(string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Error
level with correlation ID.
public void ErrorCorr(string correlationId, Exception exception, [Localizable(false)] string message)
Method parameters
- string correlationId
- Correlation ID
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Error
level with correlation ID.
public void ErrorCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueImplements: ILogger.ErrorCorr(string, string)Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Error
level and returns the exception of given type
public LoggerExt.TException ErrorCorr<TException>(string correlationId, LoggerExt.TException exception, string message = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.LoggerExt.TException exception
- Exception to be logged
- string message
- Log message.
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Error
level with correlation ID. Creates and returns the exception of given type
public LoggerExt.TException ErrorCorr<TException>(string correlationId, string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.ExceptionFilter.cs
Writes the diagnostic message at the Error
level and returns the exception of given type
public bool ErrorFltr<TException>(LoggerExt.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- net.adamec.lib.common.core.logging.LoggerExt.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
The following code logs any exception without catching it (function returns false by default)
try
{
...
}
catch (Exception e) when (Logger.FatalFltr(e)) {}
The following code catch and log the ArgumentException and logs any other exception without catching it.
try
{
...
}
catch (ArgumentException e) when (Logger.ErrorFltr(e,catchIt:true)) {}
catch (Exception e) when (Logger.FatalFltr(e)) {}
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Error
level and returns the exception of given type
public bool ErrorFltrCorr<TException>(string correlationId, LoggerExt.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.LoggerExt.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
ErrorFltr<TException>(LoggerExt.TException, string, bool)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.ExceptionPassThrough.cs
Writes the diagnostic message at the Error
level and returns given exception
public Exception ErrorPassThrough(Exception exception, string message = null)
Method parameters
- System.Exception exception
- Exception to be logged
- string message
- Log message.
- System.Exception
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Fatal
level.
public void Fatal(Dictionary<string,object> eventProperties, Exception exception, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Fatal
level.
public void Fatal(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.ExceptionPassThrough.cs
Writes the diagnostic message at the Fatal
level. Creates and returns the exception of given type
public LoggerExt.TException Fatal<TException>(string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Fatal
level with correlation ID.
public void FatalCorr(string correlationId, Exception exception, [Localizable(false)] string message)
Method parameters
- string correlationId
- Correlation ID
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Fatal
level with correlation ID.
public void FatalCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueImplements: ILogger.FatalCorr(string, string)Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Fatal
level and returns the exception of given type
public LoggerExt.TException FatalCorr<TException>(string correlationId, LoggerExt.TException exception, string message = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.LoggerExt.TException exception
- Exception to be logged
- string message
- Log message.
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Fatal
level with correlation ID. Creates and returns the exception of given type
public LoggerExt.TException FatalCorr<TException>(string correlationId, string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.LoggerExt.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.ExceptionFilter.cs
Writes the diagnostic message at the Fatal
level and returns catchIt value.
public bool FatalFltr<TException>(LoggerExt.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- net.adamec.lib.common.core.logging.LoggerExt.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
ErrorFltr<TException>(LoggerExt.TException, string, bool)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Fatal
level and returns catchIt value.
public bool FatalFltrCorr<TException>(string correlationId, LoggerExt.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.LoggerExt.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
ErrorFltr<TException>(LoggerExt.TException, string, bool)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.ExceptionPassThrough.cs
Writes the diagnostic message at the Fatal
level and returns given exception >
public Exception FatalPassThrough(Exception exception, string message = null)
Method parameters
- System.Exception exception
- Exception to be logged
- string message
- Log message.
- System.Exception
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Info
level.
public void Info(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Info
level with correlation ID.
public void InfoCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueImplements: ILogger.InfoCorr(string, string)Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.cs
Writes the item (message with optional event properties and exception) into the log
private void LogIt(LogLevel level, Dictionary<string,object> eventProperties, [Localizable(false)] string message, Exception exception = null, string stackTrace = null)
Method parameters
- NLog.LogLevel level
- Dictionary<string,object> eventProperties
- Event properties (null when no properties are provided)
- string message
- Log message
- System.Exception exception
- Optional exception to be logged
- string stackTrace
- Optional stack trace to be logged in
StackTrace
event property when the System.Exception.StackTrace of exception is empty
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.cs
Writes the item (message with optional exception) into the log
private void LogIt(LogLevel level, [Localizable(false)] string message, Exception exception = null, string stackTrace = null)
Method parameters
- NLog.LogLevel level
- string message
- Log message
- System.Exception exception
- Optional exception to be logged
- string stackTrace
- Optional stack trace to be logged in
StackTrace
event property when the System.Exception.StackTrace of exception is empty
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the item (message with optional exception) with correlation Id into the log
private void LogIt(LogLevel level, string correlationId, [Localizable(false)] string message, Exception exception = null, string stackTrace = null)
Method parameters
- NLog.LogLevel level
- string correlationId
- Correlation ID
- string message
- Log message
- System.Exception exception
- Optional exception to be logged
- string stackTrace
- Optional stack trace to be logged in
StackTrace
event property when the System.Exception.StackTrace of exception is empty
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Trace
level.
public void Trace(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Trace
level with correlation ID
public void TraceCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueImplements: ILogger.TraceCorr(string, string)Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Warn
level.
public void Warn(Dictionary<string,object> eventProperties, Exception exception, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.EventProperties.cs
Writes the diagnostic message at the Warn
level.
public void Warn(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Warn
level with correlation ID.
public void WarnCorr(string correlationId, Exception exception, [Localizable(false)] string message)
Method parameters
- string correlationId
- Correlation ID
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: LoggerExt
Sources: logging\LoggerExt.CorrelationId.cs
Writes the diagnostic message at the Warn
level with correlation ID.
public void WarnCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueImplements: ILogger.WarnCorr(string, string)Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Sources: logging\ILogger.CorrelationId.cs, logging\ILogger.cs, logging\ILogger.EventProperties.cs, logging\ILogger.ExceptionFilter.cs, logging\ILogger.ExceptionPassThrough.cs
Logger interface - wrapper around the NLog.ILogger with some additional methods
public interface ILogger : ILogger
Implemented by: net.adamec.lib.common.core.logging.LoggerExt
Implements: NLog.ILogger, NLog.ILoggerBase, NLog.ISuppress
The NLog supports having additional (custom) event properties provided to loggers and optionally rendered to logs. The event properties are represented as key-value dictionary, where key is the unique name of the property. Extended logger provides following methods to log with given set of the properties.
- Trace(Dictionary<string,object>, string) ,
- Debug(Dictionary<string,object>, string) ,
- Info(Dictionary<string,object>, string) ,
- Warn(Dictionary<string,object>, string) ,
- Error(Dictionary<string,object>, string) ,
- Fatal(Dictionary<string,object>, string) ,
- Warn(Dictionary<string,object>, Exception, string) ,
- Error(Dictionary<string,object>, Exception, string) and
- Fatal(Dictionary<string,object>, Exception, string)
Sometimes, it's useful to have an exception logging method implemented as the operation returning the exception being logged. The ErrorPassThrough(Exception, string) and FatalPassThrough(Exception, string) methods will log given exception and return it for further processing.
try
{
...
}
catch (Exception ex){
if(logger.ErrorPassThrough(ex) is MyException){
return null;
}else{
throw;
}
}
In the example above, the exception is always logged and then the decision/action is taken.
C# 6 brought the exception filters that don't unwind the stack as the exception is not catch yet when processing the filter. It can also be used for logging the exceptions without actually catching them (when the exception filter returns false
). Extended logger provides functions ErrorFltr<TException>(ILogger.TException, string, bool) and FatalFltr<TException>(ILogger.TException, string, bool) for this purpose.
try
{
...
}
catch (Exception ex) when (logger.ErrorFltr(ex,"Error here!"){
//newer called as the default return value of ErrorFltr is false
}
The example above logs but never catch all exceptions. The following code catch and log the ArgumentException and logs any other exception without catching it.
try
{
...
}
catch (ArgumentException e) when (Logger.ErrorFltr(e,catchIt:true)) { ... }
catch (Exception e) when (Logger.FatalFltr(e)) {}
Logger can also create and exception, log it and return using functions Error<TException>(string, Exception) and Fatal<TException>(string, Exception)
if(value is null) throw logger.Fatal<ArgumentNullException>("Value is null");
When logging an exception using the LoggerExt methods, the event property StackTrace
is set from System.Exception.StackTrace , when the logger creates an exception, the property is set using new StackTrace(2, true).ToString()
. In other cases when the System.Exception.StackTrace is null or empty, new StackTrace(true).ToString()
is used.
LoggerExt also provides set of methods for logging with the correlation ID (for example in integration scenarios), where the given correlation ID is set to the event property CorrelationId
. Such methods have the name ending with Corr
suffix.
Name | Modifier | Summary |
---|---|---|
Debug(Dictionary<string,object>, string) | public abstract | Writes the diagnostic message at the Debug level. |
DebugCorr(string, string) | public abstract | Writes the diagnostic message at the Debug level with correlation ID. |
Error(Dictionary<string,object>, Exception, string) | public abstract | Writes the diagnostic message at the Error level. |
Error(Dictionary<string,object>, string) | public abstract | Writes the diagnostic message at the Error level. |
Error<TException>(string, Exception) | public abstract | Writes the diagnostic message at the Error level. Creates and returns the exception of given type |
ErrorCorr(string, Exception, string) | public abstract | Writes the diagnostic message at the Error level with correlation ID. |
ErrorCorr(string, string) | public abstract | Writes the diagnostic message at the Error level with correlation ID. |
ErrorCorr<TException>(string, ILogger.TException, string) | public abstract | Writes the diagnostic message at the Error level and returns the exception of given type |
ErrorCorr<TException>(string, string, Exception) | public abstract | Writes the diagnostic message at the Error level with correlation ID. Creates and returns the exception of given type |
ErrorFltr<TException>(ILogger.TException, string, bool) | public abstract | Writes the diagnostic message at the Error level and returns the exception of given type |
ErrorFltrCorr<TException>(string, ILogger.TException, string, bool) | public abstract | Writes the diagnostic message at the Error level and returns the exception of given type |
ErrorPassThrough(Exception, string) | public abstract | Writes the diagnostic message at the Error level and returns given exception |
Fatal(Dictionary<string,object>, Exception, string) | public abstract | Writes the diagnostic message at the Fatal level. |
Fatal(Dictionary<string,object>, string) | public abstract | Writes the diagnostic message at the Fatal level. |
Fatal<TException>(string, Exception) | public abstract | Writes the diagnostic message at the Fatal level. Creates and returns the exception of given type |
FatalCorr(string, Exception, string) | public abstract | Writes the diagnostic message at the Fatal level with correlation ID. |
FatalCorr(string, string) | public abstract | Writes the diagnostic message at the Fatal level with correlation ID. |
FatalCorr<TException>(string, ILogger.TException, string) | public abstract | Writes the diagnostic message at the Fatal level and returns the exception of given type |
FatalCorr<TException>(string, string, Exception) | public abstract | Writes the diagnostic message at the Fatal level with correlation ID. Creates and returns the exception of given type |
FatalFltr<TException>(ILogger.TException, string, bool) | public abstract | Writes the diagnostic message at the Fatal level and returns catchIt value. |
FatalFltrCorr<TException>(string, ILogger.TException, string, bool) | public abstract | Writes the diagnostic message at the Fatal level and returns catchIt value. |
FatalPassThrough(Exception, string) | public abstract | Writes the diagnostic message at the Fatal level and returns given exception |
Info(Dictionary<string,object>, string) | public abstract | Writes the diagnostic message at the Info level. |
InfoCorr(string, string) | public abstract | Writes the diagnostic message at the Info level with correlation ID. |
Trace(Dictionary<string,object>, string) | public abstract | Writes the diagnostic message at the Trace level. |
TraceCorr(string, string) | public abstract | Writes the diagnostic message at the Trace level with correlation ID. |
Warn(Dictionary<string,object>, Exception, string) | public abstract | Writes the diagnostic message at the Warn level. |
Warn(Dictionary<string,object>, string) | public abstract | Writes the diagnostic message at the Warn level. |
WarnCorr(string, Exception, string) | public abstract | Writes the diagnostic message at the Warn level with correlation ID. |
WarnCorr(string, string) | public abstract | Writes the diagnostic message at the Warn level with correlation ID. |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Debug
level.
public abstract void Debug(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Debug
level with correlation ID.
public abstract void DebugCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueGo to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Error
level.
public abstract void Error(Dictionary<string,object> eventProperties, Exception exception, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Error
level.
public abstract void Error(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.ExceptionPassThrough.cs
Writes the diagnostic message at the Error
level. Creates and returns the exception of given type
public abstract ILogger.TException Error<TException>(string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.ILogger.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Error
level with correlation ID.
public abstract void ErrorCorr(string correlationId, Exception exception, [Localizable(false)] string message)
Method parameters
- string correlationId
- Correlation ID
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Error
level with correlation ID.
public abstract void ErrorCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueGo to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Error
level and returns the exception of given type
public abstract ILogger.TException ErrorCorr<TException>(string correlationId, ILogger.TException exception, string message = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.ILogger.TException exception
- Exception to be logged
- string message
- Log message.
- net.adamec.lib.common.core.logging.ILogger.TException
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Error
level with correlation ID. Creates and returns the exception of given type
public abstract ILogger.TException ErrorCorr<TException>(string correlationId, string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.ILogger.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.ExceptionFilter.cs
Writes the diagnostic message at the Error
level and returns the exception of given type
public abstract bool ErrorFltr<TException>(ILogger.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- net.adamec.lib.common.core.logging.ILogger.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
The following code logs any exception without catching it (function returns false by default)
try
{
...
}
catch (Exception e) when (Logger.FatalFltr(e)) {}
The following code catch and log the ArgumentException and logs any other exception without catching it.
try
{
...
}
catch (ArgumentException e) when (Logger.ErrorFltr(e,catchIt:true)) {}
catch (Exception e) when (Logger.FatalFltr(e)) {}
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Error
level and returns the exception of given type
public abstract bool ErrorFltrCorr<TException>(string correlationId, ILogger.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.ILogger.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
ErrorFltr<TException>(ILogger.TException, string, bool)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.ExceptionPassThrough.cs
Writes the diagnostic message at the Error
level and returns given exception
public abstract Exception ErrorPassThrough(Exception exception, string message = null)
Method parameters
- System.Exception exception
- Exception to be logged
- string message
- Log message.
- System.Exception
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Fatal
level.
public abstract void Fatal(Dictionary<string,object> eventProperties, Exception exception, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Fatal
level.
public abstract void Fatal(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.ExceptionPassThrough.cs
Writes the diagnostic message at the Fatal
level. Creates and returns the exception of given type
public abstract ILogger.TException Fatal<TException>(string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.ILogger.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Fatal
level with correlation ID.
public abstract void FatalCorr(string correlationId, Exception exception, [Localizable(false)] string message)
Method parameters
- string correlationId
- Correlation ID
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Fatal
level with correlation ID.
public abstract void FatalCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueGo to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Fatal
level and returns the exception of given type
public abstract ILogger.TException FatalCorr<TException>(string correlationId, ILogger.TException exception, string message = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.ILogger.TException exception
- Exception to be logged
- string message
- Log message.
- net.adamec.lib.common.core.logging.ILogger.TException
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Fatal
level with correlation ID. Creates and returns the exception of given type
public abstract ILogger.TException FatalCorr<TException>(string correlationId, string message, Exception innerException = null) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- string message
- Log message.
- System.Exception innerException
- Exception to be logged
- net.adamec.lib.common.core.logging.ILogger.TException
- Created exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.ExceptionFilter.cs
Writes the diagnostic message at the Fatal
level and returns catchIt value.
public abstract bool FatalFltr<TException>(ILogger.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- net.adamec.lib.common.core.logging.ILogger.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
ErrorFltr<TException>(ILogger.TException, string, bool)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Fatal
level and returns catchIt value.
public abstract bool FatalFltrCorr<TException>(string correlationId, ILogger.TException exception, string message = null, bool catchIt = false) where TException: Exception
Type parameters
- TException
- string correlationId
- Correlation ID
- net.adamec.lib.common.core.logging.ILogger.TException exception
- Exception to be logged
- string message
- Log message.
- bool catchIt
- Flag whether the exception is to be catch by filter (default is false)
- bool
- Flag whether the exception is to be catch by exception filter
This function is intended for catch exception filters. The parameter catchIt defines whether the exception filter will be applied after logging. The exception will be catch when catchIt is true, otherwise the filter is evaluated as false and it will continue with finding the catch clause (in both cases the log entry will be created)
ErrorFltr<TException>(ILogger.TException, string, bool)
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.ExceptionPassThrough.cs
Writes the diagnostic message at the Fatal
level and returns given exception
public abstract Exception FatalPassThrough(Exception exception, string message = null)
Method parameters
- System.Exception exception
- Exception to be logged
- string message
- Log message.
- System.Exception
- Pass-through exception
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Info
level.
public abstract void Info(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Info
level with correlation ID.
public abstract void InfoCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueGo to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Trace
level.
public abstract void Trace(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Trace
level with correlation ID.
public abstract void TraceCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueGo to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Warn
level.
public abstract void Warn(Dictionary<string,object> eventProperties, Exception exception, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.EventProperties.cs
Writes the diagnostic message at the Warn
level.
public abstract void Warn(Dictionary<string,object> eventProperties, [Localizable(false)] string message)
Method parameters
- Dictionary<string,object> eventProperties
- Event properties
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Warn
level with correlation ID.
public abstract void WarnCorr(string correlationId, Exception exception, [Localizable(false)] string message)
Method parameters
- string correlationId
- Correlation ID
- System.Exception exception
- Exception to be logged
- string message
- Log message.
Go to namespaces or types
Namespace: net.adamec.lib.common.core.logging
Assembly: net.adamec.lib.common.core
Type: ILogger
Sources: logging\ILogger.CorrelationId.cs
Writes the diagnostic message at the Warn
level with correlation ID.
public abstract void WarnCorr(string correlationId, [Localizable(false)] string message)
Method parameters
Return valueGo to namespaces or types
Name | Modifier | Summary |
---|---|---|
BaseDisposable | public abstract | Helper class for implementation of System.IDisposable types |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Sources: utils\BaseDisposable.cs
Helper class for implementation of System.IDisposable types
public abstract class BaseDisposable : IDisposable
Inheritance: object
Implements: IDisposable
Name | Value | Summary |
---|---|---|
DisposedFlag | 1 | Internal flag whether the object is fully disposed |
Name | Modifier | Summary |
---|---|---|
isDisposed | private | The object is disposed when equals to DisposedFlag |
isManagedDisposed | private | The managed resources are disposed when equals to DisposedFlag |
isNativeDisposed | private | The native resources are disposed when equals to DisposedFlag |
Name | Modifier | Summary |
---|---|---|
Disposed | public | Returns csharp true when the object is fully disposed |
DisposedManaged | public | Returns csharp true when the managed resources are disposed |
DisposedNative | public | Returns csharp true when the native resources are disposed |
Name | Modifier | Summary |
---|---|---|
~BaseDisposable() | protected |
Name | Modifier | Summary |
---|---|---|
AssertNotDisposed(string) | protected | Throws an System.ObjectDisposedException when the current object is disposed |
Dispose() | public | Dispose the object |
Dispose(bool) | protected | Internal implementation of dispose - free the managed and native resources using the respective methods |
DisposeManaged() | protected | Dispose any disposable managed fields or properties. |
DisposeNative() | protected | Dispose of COM objects, Handles, etc. Then set those objects to null. |
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Internal flag whether the object is fully disposed
private const int DisposedFlag = 1
Field value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
The object is disposed when equals to DisposedFlag
private int isDisposed
Field value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
The managed resources are disposed when equals to DisposedFlag
private int isManagedDisposed
Field value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
The native resources are disposed when equals to DisposedFlag
private int isNativeDisposed
Field value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Returns
true
when the object is fully disposed
public bool Disposed { get; }
Property value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Returns
true
when the managed resources are disposed
public bool DisposedManaged { get; }
Property value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Returns
true
when the native resources are disposed
public bool DisposedNative { get; }
Property value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
~BaseDisposable()
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Throws an System.ObjectDisposedException when the current object is disposed
protected void AssertNotDisposed(string message = null)
Method parameters
- string message
- Optional exception message
- System.ObjectDisposedException
- Current object is disposed
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Dispose the object
public void Dispose()
Return value
Implements: IDisposable.DisposeGo to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Internal implementation of dispose - free the managed and native resources using the respective methods
protected virtual void Dispose(bool disposing)
Method parameters
- bool disposing
- True to dispose both managed and native resources, false to dispose the native resources only
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Dispose any disposable managed fields or properties.
protected virtual void DisposeManaged()
Return value
Go to namespaces or types
Namespace: net.adamec.lib.common.core.utils
Assembly: net.adamec.lib.common.core
Type: BaseDisposable
Sources: utils\BaseDisposable.cs
Dispose of COM objects, Handles, etc. Then set those objects to null.
protected virtual void DisposeNative()
Return value
Go to namespaces or types