Table of Contents

Class Logger

Namespace
Coherence.Log
Assembly
Coherence.Log.dll
public class Logger
Inheritance
Logger
Derived

Constructors

Logger(Type, object, IEnumerable<ILogTarget>)

public Logger(Type source = null, object context = null, IEnumerable<ILogTarget> logTargets = null)

Parameters

source Type
context object
logTargets IEnumerable<ILogTarget>

Fields

prefixArgs

protected readonly List<(string key, object value)> prefixArgs

Field Value

List<(string key, object value)>

Properties

Context

public object Context { get; set; }

Property Value

object

LogTargets

public IReadOnlyList<ILogTarget> LogTargets { get; }

Property Value

IReadOnlyList<ILogTarget>

UseWatermark

public bool UseWatermark { get; set; }

Property Value

bool

WithLogger

protected Logger WithLogger { get; set; }

Property Value

Logger

Methods

AddLogTarget(ILogTarget)

public void AddLogTarget(ILogTarget logTarget)

Parameters

logTarget ILogTarget

AppendArgs(StringBuilder, ICollection<(string key, object value)>, bool)

protected virtual StringBuilder AppendArgs(StringBuilder logBuilder, ICollection<(string key, object value)> args, bool useTab = true)

Parameters

logBuilder StringBuilder
args ICollection<(string key, object value)>
useTab bool

Returns

StringBuilder

AppendLevel(StringBuilder, LogLevel, bool)

protected virtual StringBuilder AppendLevel(StringBuilder logBuilder, LogLevel level, bool noTrailingSpace = false)

Parameters

logBuilder StringBuilder
level LogLevel
noTrailingSpace bool

Returns

StringBuilder

AppendPrefix(StringBuilder)

protected virtual StringBuilder AppendPrefix(StringBuilder logBuilder)

Parameters

logBuilder StringBuilder

Returns

StringBuilder

AppendSource(StringBuilder)

protected StringBuilder AppendSource(StringBuilder logBuilder)

Parameters

logBuilder StringBuilder

Returns

StringBuilder

AppendTimestamp(StringBuilder, bool)

protected virtual StringBuilder AppendTimestamp(StringBuilder logBuilder, bool noTrailingSpace = false)

Parameters

logBuilder StringBuilder
noTrailingSpace bool

Returns

StringBuilder

BuildAndPrintLog(LogLevel, string, params (string key, object value)[])

protected virtual bool BuildAndPrintLog(LogLevel level, string log, params (string key, object value)[] args)

Parameters

level LogLevel
log string
args (string key, object value)[]

Returns

bool

Debug(string, params (string key, object value)[])

[Conditional("COHERENCE_LOG_DEBUG")]
public virtual void Debug(string log, params (string key, object value)[] args)

Parameters

log string
args (string key, object value)[]

Dispose()

public void Dispose()

Error(string, params (string key, object value)[])

public virtual void Error(string log, params (string key, object value)[] args)

Parameters

log string
args (string key, object value)[]

GatherPrefixArgs(params (string key, object value)[])

protected virtual (string key, object value)[] GatherPrefixArgs(params (string key, object value)[] args)

Parameters

args (string key, object value)[]

Returns

(string key, object value)[]

Info(string, params (string key, object value)[])

public virtual void Info(string log, params (string key, object value)[] args)

Parameters

log string
args (string key, object value)[]

Log(LogLevel, string, params (string key, object value)[])

public void Log(LogLevel level, string log, params (string key, object value)[] args)

Parameters

level LogLevel
log string
args (string key, object value)[]

LogImpl(LogLevel, string, params (string key, object value)[])

protected virtual void LogImpl(LogLevel level, string log, params (string key, object value)[] args)

Parameters

level LogLevel
log string
args (string key, object value)[]

NoWatermark()

public Logger NoWatermark()

Returns

Logger

Trace(string, params (string key, object value)[])

[Conditional("COHERENCE_LOG_TRACE")]
public virtual void Trace(string log, params (string key, object value)[] args)

Parameters

log string
args (string key, object value)[]

Warning(string, params (string key, object value)[])

public virtual void Warning(string log, params (string key, object value)[] args)

Parameters

log string
args (string key, object value)[]

With(Type)

public virtual Logger With(Type source)

Parameters

source Type

Returns

Logger

WithArgs(params (string key, object value)[])

public virtual Logger WithArgs(params (string key, object value)[] args)

Parameters

args (string key, object value)[]

Returns

Logger

With<TSource>()

public virtual Logger With<TSource>()

Returns

Logger

Type Parameters

TSource

Events

OnLog

public static event Logger.LogDelegate OnLog

Event Type

Logger.LogDelegate