Class Logger
Main class of Logging library.
Contains Sinks, unique identifier Logger
Implements
Inherited Members
Namespace: Unity.Logging
Assembly: Unity.Logging.dll
Syntax
public class Logger : IDisposable
Constructors
Logger(LoggerConfig)
Constructor
Declaration
public Logger(LoggerConfig config)
Parameters
Type | Name | Description |
---|---|---|
Logger |
config | Contains configuration of the logger |
Fields
Config
Config that was used in Logger construction
Declaration
public readonly LoggerConfig Config
Field Value
Type | Description |
---|---|
Logger |
Handle
Unique id
Declaration
public readonly LoggerHandle Handle
Field Value
Type | Description |
---|---|
Logger |
Properties
MinimalLogLevelAcrossAllSystems
Declaration
public LogLevel MinimalLogLevelAcrossAllSystems { get; }
Property Value
Type | Description |
---|---|
Log |
SinksCount
Returns count of sinks that this Logger has
Declaration
public int SinksCount { get; }
Property Value
Type | Description |
---|---|
int |
Methods
AddSink(SinkConfiguration)
Creates new sink using Sink
Declaration
public SinkSystemBase AddSink(SinkConfiguration sc)
Parameters
Type | Name | Description |
---|---|---|
Sink |
sc | Configuration to create a sink |
Returns
Type | Description |
---|---|
Sink |
Newly created sink |
AddSink(SinkConfiguration, ref LogControllerScopedLock)
Creates new sink using Sink
Declaration
public SinkSystemBase AddSink(SinkConfiguration sc, ref LogControllerScopedLock logLock)
Parameters
Type | Name | Description |
---|---|---|
Sink |
sc | Configuration to create a sink |
Log |
logLock | Lock that holds this logger's LogController |
Returns
Type | Description |
---|---|
Sink |
Newly created sink |
Dispose()
Disposes the Logger. See IDisposable
Declaration
public void Dispose()
GetOrCreateSink<T>(SinkConfiguration)
Get or create sink of type T
Declaration
public T GetOrCreateSink<T>(SinkConfiguration sc) where T : SinkSystemBase
Parameters
Type | Name | Description |
---|---|---|
Sink |
sc | Configuration of the sink |
Returns
Type | Description |
---|---|
T | Existing or created sink |
Type Parameters
Name | Description |
---|---|
T | SinkSystemBase |
GetSink(int)
Returns sink number i. Used for debugging
Declaration
public SinkSystemBase GetSink(int i)
Parameters
Type | Name | Description |
---|---|---|
int | i | index of the sink |
Returns
Type | Description |
---|---|
Sink |
Returns sink number i |
GetSink<T>()
Returns the sink of type T. Will return first one if there are several ones of the type T
Declaration
public T GetSink<T>() where T : SinkSystemBase
Returns
Type | Description |
---|---|
T | Existing sink of type T or default |
Type Parameters
Name | Description |
---|---|
T | SinkSystemBase type |
HasSinksFor(LogLevel)
Returns true if this Logger can process messages with Log
Declaration
public bool HasSinksFor(LogLevel level)
Parameters
Type | Name | Description |
---|---|---|
Log |
level |
Returns
SetMinimalLogLevelAcrossAllSinks(LogLevel)
Changes LogLevel for all sinks in the logger. No need to call Update
Declaration
public void SetMinimalLogLevelAcrossAllSinks(LogLevel newLogLevel)
Parameters
Type | Name | Description |
---|---|---|
Log |
newLogLevel | LogLevel to set to all sinks in the logger |
UpdateMinimalLogLevelAcrossAllSinks()
Method that updates internal cached MinimalLogLevelAcrossAllSinks, and HasNoSinks please call it if you update sink's MinimalLogLevel or add/remove sinks
Update will take effect only after logger's update because of async nature of the logging. So if you want to do the change synchronously - please call Flush
Declaration
public void UpdateMinimalLogLevelAcrossAllSinks()