Joutsen Logging v0.5.0+26-g72240ac
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Joutsen.Logging.MethodScopedLogger< SourceType > Class Template Reference

A scoped logger that uses a generic type and a method as the scope. More...

Public Member Functions

 MethodScopedLogger (Logger logger, int offset, LogRecord endRecord=null)
 Creates a new instance with a call stack offset to determine the mehtodName.
 
 MethodScopedLogger (Logger logger, [CallerMemberName]string methodName=null, LogRecord endRecord=null)
 Creates a new instance with a method name.
 
- Public Member Functions inherited from Joutsen.Logging.ScopedLogger
 ScopedLogger (Logger logger, Scope scope, LogRecord endRecord=null)
 Creates a new instance for a specific scope.
 
override Guid Log (LogRecord record)
 Logs a record.
 
override void Dispose ()
 Writes the end record and frees used resources.
 
- Public Member Functions inherited from Joutsen.Logging.AbstractLogger
void Dispose ()
 
Guid Log (LogLevel level, string message, params object[] parameters)
 Logs a message of a specific log level.
 
Guid Log (LogLevel level, string message, object parameter)
 Logs a message of a specific log level.
 
Guid Log (LogLevel level, string message, Map< string, object > parameters)
 Logs a message of a specific log level.
 
Guid Log (LogLevel level, string message, IEnumerable listParameter)
 Logs a message of a specific log level with a list as parameter.
 
Guid Error (Exception exception, string message, Map< string, object > parameters)
 Logs an exception with an additional message.
 
Guid Error (Exception exception, string message, object parameter)
 Logs an exception with an additional message.
 
Guid Error (Exception exception, string message, params object[] parameters)
 Logs an exception with an additional message.
 
Guid Error (Exception exception)
 Logs an System.Exception as an error.
 
Guid Error (string message, Map< string, object > parameters)
 Logs an error message with parameters.
 
Guid Error (string message, object parameter)
 Logs an error message with parameters.
 
Guid Error (string message, params object[] parameters)
 Logs an error message with parameters.
 
Guid Error (string message, IEnumerable listParameter)
 Logs an error message with a list.
 
Guid Warning (string message, Map< string, object > parameters)
 Logs a warning message with parameters.
 
Guid Warning (string message, object parameter)
 Logs a warning message with parameters.
 
Guid Warning (string message, params object[] parameters)
 Logs a warning message with parameters.
 
Guid Warning (string message, IEnumerable listParameter)
 Logs an warning message with a list.
 
Guid Info (string message, Map< string, object > parameters)
 Logs an informational message with parameters.
 
Guid Info (string message, object parameter)
 Logs an informational message with parameters.
 
Guid Info (string message, params object[] parameters)
 Logs an informational message with parameters.
 
Guid Info (string message, IEnumerable listParameter)
 Logs an informational message with a list.
 
Guid Detail (string message, Map< string, object > parameters)
 Logs a detail message with parameters.
 
Guid Detail (string message, object parameter)
 Logs a detail message with parameters.
 
Guid Detail (string message, params object[] parameters)
 Logs a detail message with parameters.
 
Guid Detail (string message, IEnumerable listParameter)
 Logs a detail message with a list.
 
Guid Verbose (string message, Map< string, object > parameters)
 Logs a verbose message with parameters.
 
Guid Verbose (string message, object parameter)
 Logs a verbose message with parameters.
 
Guid Verbose (string message, params object[] parameters)
 Logs a verbose message with parameters.
 
Guid Verbose (string message, IEnumerable listParameter)
 Logs a verbose message with a list.
 

Additional Inherited Members

- Protected Member Functions inherited from Joutsen.Logging.ScopedLogger
void AddScope (LogRecord record)
 Adds the scope of this logger to a log record unless that record already has a scope.
 
- Protected Member Functions inherited from Joutsen.Logging.AbstractLogger
virtual bool IsLoggable (LogRecord record)
 Checks if a record is loggabe by this instance of a logger.
 
- Protected Attributes inherited from Joutsen.Logging.ScopedLogger
Logger logger
 The logger that actually handles the records, usually the one that creates this instance.
 
LogRecord endRecord
 the record that will be written when the logger instance is disposed of.
 
- Properties inherited from Joutsen.Logging.ScopedLogger
virtual Scope Scope [get, protected set]
 The scope used by the logger to create records.
 
- Events inherited from Joutsen.Logging.AbstractLogger
Action< LogRecord > Publish
 

Detailed Description

A scoped logger that uses a generic type and a method as the scope.

Since
Unreleased

Constructor & Destructor Documentation

◆ MethodScopedLogger() [1/2]

Joutsen.Logging.MethodScopedLogger< SourceType >.MethodScopedLogger ( Logger  logger,
int  offset,
LogRecord  endRecord = null 
)

Creates a new instance with a call stack offset to determine the mehtodName.

Parameters
loggera fully configured logger that handles the writing of the records
offsetthe offset of the StackFrame to use to find the name of the method.
endRecordan optional record that is created when this instance is disposed of.
Remarks
The constructor will use the StackFrame to find the right methodName. It will also check if the method name belongs to the type defined as the generic parameter if the instance. The name will be null if the types do not match: This constructor should only be used when it is not possible to determine the name of the method directly. The StackFrame used is not recommended for production. This constructor is only included to cover some rare cases where the methodName could not be determined otherwise. It is recommended to use the other constructor whenever possible.

◆ MethodScopedLogger() [2/2]

Joutsen.Logging.MethodScopedLogger< SourceType >.MethodScopedLogger ( Logger  logger,
[CallerMemberName] string  methodName = null,
LogRecord  endRecord = null 
)

Creates a new instance with a method name.

Parameters
loggera fully configured logger that handles the writing of the records
methodNamethe name of a method that deines the scope. If not defined by the caller, the compiler will fill in the name of the calling method.
endRecordan optional record that is created when this instance is disposed of.