Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Logging.Logger Class Reference

Implementation of logging More...

Inheritance diagram for Sphyrnidae.Common.Logging.Logger:
Sphyrnidae.Common.Logging.Interfaces.ILogger

Public Member Functions

 Logger (ILoggerConfiguration config, ILoggers loggers, IServiceProvider provider, IAlert alert, LongRunningInformation longRunningInfo, HttpResponseInformation httpResponseInfo, IApplicationSettings app, IEmail email)
 Note that I'm only injecting ILoggerConfiguration, and all the others are being looked up via Service Locator. This seemed like an easier pattern to use instead of having a large interface listing into constructor More...
 
virtual void Generic (BaseLogInformation info, Action errorAction=null)
 
virtual void Entry (TimerBaseInformation info, Action errorAction=null)
 
virtual void Exit (TimerBaseInformation info, Action errorAction=null)
 
virtual void Log (TraceEventType severity, string message, string category="")
 Logs a generic message More...
 
virtual void Unauthorized (string message)
 Logs an unauthorized access to the system More...
 
virtual TimerInformation TimerStart (string name)
 Will log how long the enclosed action took (from TimerStart to TimerEnd) More...
 
virtual void TimerEnd (TimerInformation info)
 Logs the actual time an operation lasted (in milliseconds) More...
 
virtual void Custom1< T > (T obj, string message="")
 Logs a generic object More...
 
virtual void Custom2< T > (T obj, string message="")
 Logs a generic object More...
 
virtual void Custom3< T > (T obj, string message="")
 Logs a generic object More...
 
virtual CustomTimerInformation1< T1, T2 > CustomTimer1Start< T1, T2 > (T1 obj, string message="")
 Will log a custom timer object More...
 
virtual CustomTimerInformation2< T1, T2 > CustomTimer2Start< T1, T2 > (T1 obj, string message="")
 Will log a custom timer object More...
 
virtual CustomTimerInformation3< T1, T2 > CustomTimer3Start< T1, T2 > (T1 obj, string message="")
 Will log a custom timer object More...
 
virtual void CustomTimerEnd< T1, T2 > (CustomTimerInformation< T1, T2 > info, T2 obj)
 Logs the actual time a custom timer took (in milliseconds) More...
 
virtual AttributeInformation AttributeEntry (string attributeName, Dictionary< string, string > parameters)
 Will log an Attribute call More...
 
virtual void AttributeExit (AttributeInformation info)
 Logs the actual time the attribute took (in milliseconds), as well as the result More...
 
virtual async Task< ApiInformationApiEntry ()
 Will log all configurable information about an API call More...
 
virtual void ApiExit (ApiInformation info, int statusCode, string result)
 Logs the actual time API took (in milliseconds), as well as the result More...
 
virtual async Task ApiExit (ApiInformation info, HttpResponse response)
 Logs the actual time API took (in milliseconds), as well as the result More...
 
virtual DatabaseInformation DatabaseEntry (string cnnName, string command, object args=null)
 Will log all configurable information about a database call More...
 
virtual void DatabaseExit (DatabaseInformation info)
 Logs the actual time the database call took (in milliseconds) More...
 
virtual WebServiceInformation WebServiceEntry (HttpHeaders headers, string name, string url, string method, object data=null)
 Will log all configurable information about a web service call More...
 
virtual void WebServiceExit (WebServiceInformation info, int statusCode, string result)
 Logs the actual time the web service call took (in milliseconds), and optionally the result More...
 
virtual async Task WebServiceExit (WebServiceInformation info, HttpResponseMessage response)
 Logs the actual time the web service call took (in milliseconds), and optionally the result More...
 
virtual MiddlewareInformation MiddlewareEntry (string name)
 Will log information about a middleware component More...
 
virtual void MiddlewareExit (MiddlewareInformation info)
 Logs the actual time the middleware took (in milliseconds) More...
 
virtual void HiddenException (Exception e, bool messageOnly)
 Will log all hidden exception information More...
 
virtual void HiddenException (Exception e, string title="", bool messageOnly=true)
 Will log all hidden exception information More...
 
virtual Guid Exception (Exception e, bool messageOnly)
 Will log all exception information More...
 
virtual Guid Exception (Exception e, string title="", bool messageOnly=false)
 Will log all exception information More...
 

Protected Member Functions

void DoLog (BaseLogInformation info, Action errorAction=null)
 
void DoUpdate (TimerBaseInformation info, Action errorAction=null)
 

Properties

ILoggerConfiguration Config [get]
 
ILoggers Loggers [get]
 
IServiceProvider Provider [get]
 
IAlert Alert [get]
 
LongRunningInformation LongRunningInfo [get]
 
HttpResponseInformation HttpResponseInfo [get]
 
IApplicationSettings App [get]
 
IEmail EmailImpl [get]
 

Detailed Description

Implementation of logging

All calls will be handled asynchronously and the actual logging occurs in this class

Constructor & Destructor Documentation

◆ Logger()

Sphyrnidae.Common.Logging.Logger.Logger ( ILoggerConfiguration  config,
ILoggers  loggers,
IServiceProvider  provider,
IAlert  alert,
LongRunningInformation  longRunningInfo,
HttpResponseInformation  httpResponseInfo,
IApplicationSettings  app,
IEmail  email 
)

Note that I'm only injecting ILoggerConfiguration, and all the others are being looked up via Service Locator. This seemed like an easier pattern to use instead of having a large interface listing into constructor

Member Function Documentation

◆ ApiEntry()

virtual async Task<ApiInformation> Sphyrnidae.Common.Logging.Logger.ApiEntry ( )
virtual

Will log all configurable information about an API call

Call this method when first entering an API method The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/ApiInformation

Returns
The object which keeps the api information (to be passed into ApiExit)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ ApiExit() [1/2]

virtual async Task Sphyrnidae.Common.Logging.Logger.ApiExit ( ApiInformation  info,
HttpResponse  response 
)
virtual

Logs the actual time API took (in milliseconds), as well as the result

This should be called after ApiEntry

Parameters
infoThe object with the api information which was returned from ApiEntry
responseThe HttpResponse object

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ ApiExit() [2/2]

virtual void Sphyrnidae.Common.Logging.Logger.ApiExit ( ApiInformation  info,
int  statusCode,
string  result 
)
virtual

Logs the actual time API took (in milliseconds), as well as the result

This should be called after ApiEntry

Parameters
infoThe object with the api information which was returned from ApiEntry
statusCodeThe http status code of the result
resultThe full http result

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ AttributeEntry()

virtual AttributeInformation Sphyrnidae.Common.Logging.Logger.AttributeEntry ( string  attributeName,
Dictionary< string, string >  parameters 
)
virtual

Will log an Attribute call

Call this method when first entering an attribute

Parameters
attributeNameThe name of the attribute
parametersThe parameters into the attribute
Returns
The object which keeps the api information (to be passed into AttributeExit)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ AttributeExit()

virtual void Sphyrnidae.Common.Logging.Logger.AttributeExit ( AttributeInformation  info)
virtual

Logs the actual time the attribute took (in milliseconds), as well as the result

This should be called after AttributeEntry

Parameters
infoThe object with the attribute information which was returned from AttributeEntry

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Custom1< T >()

virtual void Sphyrnidae.Common.Logging.Logger.Custom1< T > ( obj,
string  message = "" 
)
virtual

Logs a generic object

To use this, you should create a class inheriting from CustomInformation1. Fill out all of the required abstract methods (and override any others) You will need to register this service: Eg. services.TryAddTransient<CustomInformation1<Widget>, WidgetInformation>(); When you call this method, the type needs to match... otherwise runtime exception with service locator.

Parameters
objYour object to be logged
messageOptional message to be logged (if not supplied in your inherited class)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Custom2< T >()

virtual void Sphyrnidae.Common.Logging.Logger.Custom2< T > ( obj,
string  message = "" 
)
virtual

Logs a generic object

To use this, you should create a class inheriting from CustomInformation2. Fill out all of the required abstract methods (and override any others) You will need to register this service: Eg. services.TryAddTransient<CustomInformation2<Widget>, WidgetInformation>(); When you call this method, the type needs to match... otherwise runtime exception with service locator.

Parameters
objYour object to be logged
messageOptional message to be logged (if not supplied in your inherited class)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Custom3< T >()

virtual void Sphyrnidae.Common.Logging.Logger.Custom3< T > ( obj,
string  message = "" 
)
virtual

Logs a generic object

To use this, you should create a class inheriting from CustomInformation3. Fill out all of the required abstract methods (and override any others) You will need to register this service: Eg. services.TryAddTransient<CustomInformation3<Widget>, WidgetInformation>(); When you call this method, the type needs to match... otherwise runtime exception with service locator.

Parameters
objYour object to be logged
messageOptional message to be logged (if not supplied in your inherited class)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ CustomTimer1Start< T1, T2 >()

virtual CustomTimerInformation1<T1, T2> Sphyrnidae.Common.Logging.Logger.CustomTimer1Start< T1, T2 > ( T1  obj,
string  message = "" 
)
virtual

Will log a custom timer object

To use this, you should create a class inheriting from CustomTimerInformation1. Fill out all of the required abstract methods (and override any others) You will need to register this service: Eg. services.TryAddTransient<CustomTimerInformation1<Widget, Foo>, WidgetTimerInformation>(); When you call this method, the type needs to match... otherwise runtime exception with service locator.

Parameters
objYour object to be logged
messageOptional message to be logged (if not supplied in your inherited class)
Returns
The object which keeps the timer (to be passed into TimerEnd)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ CustomTimer2Start< T1, T2 >()

virtual CustomTimerInformation2<T1, T2> Sphyrnidae.Common.Logging.Logger.CustomTimer2Start< T1, T2 > ( T1  obj,
string  message = "" 
)
virtual

Will log a custom timer object

To use this, you should create a class inheriting from CustomTimerInformation2. Fill out all of the required abstract methods (and override any others) You will need to register this service: Eg. services.TryAddTransient<CustomTimerInformation2<Widget, Foo>, WidgetTimerInformation>(); When you call this method, the type needs to match... otherwise runtime exception with service locator.

Parameters
objYour object to be logged
messageOptional message to be logged (if not supplied in your inherited class)
Returns
The object which keeps the timer (to be passed into TimerEnd)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ CustomTimer3Start< T1, T2 >()

virtual CustomTimerInformation3<T1, T2> Sphyrnidae.Common.Logging.Logger.CustomTimer3Start< T1, T2 > ( T1  obj,
string  message = "" 
)
virtual

Will log a custom timer object

To use this, you should create a class inheriting from CustomTimerInformation3. Fill out all of the required abstract methods (and override any others) You will need to register this service: Eg. services.TryAddTransient<CustomTimerInformation3<Widget, Foo>, WidgetTimerInformation>(); When you call this method, the type needs to match... otherwise runtime exception with service locator.

Parameters
objYour object to be logged
messageOptional message to be logged (if not supplied in your inherited class)
Returns
The object which keeps the timer (to be passed into TimerEnd)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ CustomTimerEnd< T1, T2 >()

virtual void Sphyrnidae.Common.Logging.Logger.CustomTimerEnd< T1, T2 > ( CustomTimerInformation< T1, T2 >  info,
T2  obj 
)
virtual

Logs the actual time a custom timer took (in milliseconds)

This should be called after CustomTimerStart

Parameters
infoThe object with the timer which was returned from CustomTimerStart
objAny object to store additional user-supplied information

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ DatabaseEntry()

virtual DatabaseInformation Sphyrnidae.Common.Logging.Logger.DatabaseEntry ( string  cnnName,
string  command,
object  args = null 
)
virtual

Will log all configurable information about a database call

Call this method right before making a call to a database The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/DatabaseInformation

Parameters
cnnNameThe "nice" name for which database/connection you are using (don't include sensitive information)
commandThe command being executed
argsAny parameters for the command
Returns
The object which keeps the database information (to be passed into DatabaseExit)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ DatabaseExit()

virtual void Sphyrnidae.Common.Logging.Logger.DatabaseExit ( DatabaseInformation  info)
virtual

Logs the actual time the database call took (in milliseconds)

This should be called after DatabaseEntry

Parameters
infoThe object with the database information which was returned from DatabaseEntry

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ DoLog()

void Sphyrnidae.Common.Logging.Logger.DoLog ( BaseLogInformation  info,
Action  errorAction = null 
)
protected

◆ DoUpdate()

void Sphyrnidae.Common.Logging.Logger.DoUpdate ( TimerBaseInformation  info,
Action  errorAction = null 
)
protected

◆ Entry()

virtual void Sphyrnidae.Common.Logging.Logger.Entry ( TimerBaseInformation  info,
Action  errorAction = null 
)
virtual

◆ Exception() [1/2]

virtual Guid Sphyrnidae.Common.Logging.Logger.Exception ( Exception  e,
bool  messageOnly 
)
virtual

Will log all exception information

Call this method whenever an exception has occurred that has stopped processing of the request The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/ExceptionInformation

Parameters
eThe exception that was thrown
messageOnlyOptional. Default = true If true, this will only log the exception text and type If false, all relevant information will be logged (eg. Stack Trace)
Returns
An identifier so the user can contact customer service

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Exception() [2/2]

virtual Guid Sphyrnidae.Common.Logging.Logger.Exception ( Exception  e,
string  title = "",
bool  messageOnly = false 
)
virtual

Will log all exception information

Call this method whenever an exception has occurred that has stopped processing of the request The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/ExceptionInformation

Parameters
eThe exception that was thrown
titleThe type of exception, or a "nice" name you are giving this
messageOnlyOptional. Default = true If true, this will only log the exception text and type If false, all relevant information will be logged (eg. Stack Trace)
Returns
An identifier so the user can contact customer service

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Exit()

virtual void Sphyrnidae.Common.Logging.Logger.Exit ( TimerBaseInformation  info,
Action  errorAction = null 
)
virtual

◆ Generic()

virtual void Sphyrnidae.Common.Logging.Logger.Generic ( BaseLogInformation  info,
Action  errorAction = null 
)
virtual

◆ HiddenException() [1/2]

virtual void Sphyrnidae.Common.Logging.Logger.HiddenException ( Exception  ex,
bool  messageOnly 
)
virtual

Will log all hidden exception information

Call this method whenever an exception has occurred that will be ignored The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/ExceptionInformation

Parameters
exThe exception that is being hidden
messageOnlyOptional. Default = true If true, this will only log the exception text and type If false, all relevant information will be logged (eg. Stack Trace)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ HiddenException() [2/2]

virtual void Sphyrnidae.Common.Logging.Logger.HiddenException ( Exception  ex,
string  title = "",
bool  messageOnly = true 
)
virtual

Will log all hidden exception information

Call this method whenever an exception has occurred that will be ignored The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/ExceptionInformation

Parameters
exThe exception that is being hidden
titleThe type of exception, or a "nice" name you are giving this
messageOnlyOptional. Default = true If true, this will only log the exception text and type If false, all relevant information will be logged (eg. Stack Trace)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Log()

virtual void Sphyrnidae.Common.Logging.Logger.Log ( TraceEventType  severity,
string  message,
string  category = "" 
)
virtual

Logs a generic message

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ MiddlewareEntry()

virtual MiddlewareInformation Sphyrnidae.Common.Logging.Logger.MiddlewareEntry ( string  name)
virtual

Will log information about a middleware component

Parameters
nameThe name of the middleware component
Returns
The object which keeps the middleware information (to be passed into MiddlewareExit)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ MiddlewareExit()

virtual void Sphyrnidae.Common.Logging.Logger.MiddlewareExit ( MiddlewareInformation  info)
virtual

Logs the actual time the middleware took (in milliseconds)

Parameters
infoThe object with the middleware information which was returned from MiddlewareEntry

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ TimerEnd()

virtual void Sphyrnidae.Common.Logging.Logger.TimerEnd ( TimerInformation  info)
virtual

Logs the actual time an operation lasted (in milliseconds)

This should be called after TimerStart

Parameters
infoThe object with the timer which was returned from TimerStart

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ TimerStart()

virtual TimerInformation Sphyrnidae.Common.Logging.Logger.TimerStart ( string  name)
virtual

Will log how long the enclosed action took (from TimerStart to TimerEnd)

Call this function at any place in your code where you want to capture helpful timing information

Parameters
nameThe name you are giving this timer
Returns
The object which keeps the timer (to be passed into TimerEnd)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ Unauthorized()

virtual void Sphyrnidae.Common.Logging.Logger.Unauthorized ( string  message)
virtual

Logs an unauthorized access to the system

This should be called on your authentication/authorization checks if they fail

Parameters
messageThe message to log

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ WebServiceEntry()

virtual WebServiceInformation Sphyrnidae.Common.Logging.Logger.WebServiceEntry ( HttpHeaders  headers,
string  name,
string  url,
string  method,
object  data = null 
)
virtual

Will log all configurable information about a web service call

Call this method right before making a web service call The actual information that is collected (or if this even logs out) will be given by your implementation of ILoggerConfiguration/WebServiceInformation

Parameters
headersThe collection of HTTP headers that will have logger prefix added
nameThe unique name of the route you are hitting
urlThe endpoint that is being hit
methodThe HTTP method: GET POST PUT DELETE OTHER
dataAny additional data being sent in the body of the request
Returns
The object which keeps the web service information (to be passed into WebServiceExit)

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ WebServiceExit() [1/2]

virtual async Task Sphyrnidae.Common.Logging.Logger.WebServiceExit ( WebServiceInformation  info,
HttpResponseMessage  response 
)
virtual

Logs the actual time the web service call took (in milliseconds), and optionally the result

This should be called after WebServiceEntry

Parameters
infoThe object with the web service information which was returned from WebServiceEntry
responseThe result from the web service call

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

◆ WebServiceExit() [2/2]

virtual void Sphyrnidae.Common.Logging.Logger.WebServiceExit ( WebServiceInformation  info,
int  statusCode,
string  result 
)
virtual

Logs the actual time the web service call took (in milliseconds), and optionally the result

This should be called after WebServiceEntry

Parameters
infoThe object with the web service information which was returned from WebServiceEntry
statusCodeThe http status code of the result
resultThe full http result

Implements Sphyrnidae.Common.Logging.Interfaces.ILogger.

Property Documentation

◆ Alert

IAlert Sphyrnidae.Common.Logging.Logger.Alert
getprotected

◆ App

IApplicationSettings Sphyrnidae.Common.Logging.Logger.App
getprotected

◆ Config

ILoggerConfiguration Sphyrnidae.Common.Logging.Logger.Config
getprotected

◆ EmailImpl

IEmail Sphyrnidae.Common.Logging.Logger.EmailImpl
getprotected

◆ HttpResponseInfo

HttpResponseInformation Sphyrnidae.Common.Logging.Logger.HttpResponseInfo
getprotected

◆ Loggers

ILoggers Sphyrnidae.Common.Logging.Logger.Loggers
getprotected

◆ LongRunningInfo

LongRunningInformation Sphyrnidae.Common.Logging.Logger.LongRunningInfo
getprotected

◆ Provider

IServiceProvider Sphyrnidae.Common.Logging.Logger.Provider
getprotected

The documentation for this class was generated from the following file: