Class Logger
Main class of Logging library. Contains Sinks, unique identifier LoggerHandle
Namespace: Unity.Logging
Syntax
public class Logger : IDisposable
Constructors
Logger(LoggerConfig)
Constructor
Declaration
public Logger(LoggerConfig config)
Parameters
Type | Name | Description |
---|---|---|
LoggerConfig | config | Contains configuration of the logger |
Fields
Config
Config that was used in Logger construction
Declaration
public readonly LoggerConfig Config
Field Value
Type | Description |
---|---|
LoggerConfig |
Handle
Unique id
Declaration
public readonly LoggerHandle Handle
Field Value
Type | Description |
---|---|
LoggerHandle |
Properties
MinimalLogLevelAcrossAllSystems
Declaration
public LogLevel MinimalLogLevelAcrossAllSystems { get; }
Property Value
Type | Description |
---|---|
LogLevel |
SinksCount
Returns count of sinks that this Logger has
Declaration
public int SinksCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
AddSink(SinkConfiguration)
Creates new sink using SinkConfiguration
Declaration
public ISinkSystemInterface AddSink(SinkConfiguration sc)
Parameters
Type | Name | Description |
---|---|---|
SinkConfiguration | sc | Configuration to create a sink |
Returns
Type | Description |
---|---|
ISinkSystemInterface | Newly created sink |
Dispose()
Disposes the Logger. See
Declaration
public void Dispose()
GetOrCreateSink<T>(SinkConfiguration<T>)
Get or create sink of type T
Declaration
public T GetOrCreateSink<T>(SinkConfiguration<T> sc)
where T : ISinkSystemInterface, new()
Parameters
Type | Name | Description |
---|---|---|
SinkConfiguration<T> | sc | Configuration of the sink |
Returns
Type | Description |
---|---|
T | Existing or created sink |
Type Parameters
Name | Description |
---|---|
T | ISinkSystemInterface |
GetSink(Int32)
Returns sink number i. Used for debugging
Declaration
public ISinkSystemInterface GetSink(int i)
Parameters
Type | Name | Description |
---|---|---|
Int32 | i | index of the sink |
Returns
Type | Description |
---|---|
ISinkSystemInterface | 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 : ISinkSystemInterface, new()
Returns
Type | Description |
---|---|
T | Existing sink of type T or default |
Type Parameters
Name | Description |
---|---|
T | ISinkSystemInterface sink type |
HasSinksFor(LogLevel)
Returns true if this Logger can process messages with LogLevel level.
Declaration
public bool HasSinksFor(LogLevel level)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level |
Returns
Type | Description |
---|---|
Boolean | True if this Logger can process messages with LogLevel level. |
ScheduleUpdate(JobHandle)
Schedules Update job for this Logger. It will sort all messages by timestamp, then call all Sinks in parallel. After all sinks are done: Cleanup job that will clean and flip DispatchQueue will be called. And then LogMemoryManager's Update job will be executed.
Declaration
public JobHandle ScheduleUpdate(JobHandle dependency)
Parameters
Type | Name | Description |
---|---|---|
JobHandle | dependency | Any dependency that should be executed before this Update |
Returns
Type | Description |
---|---|
JobHandle | JobHandle for the Update job |
SetMinimalLogLevelAcrossAllSinks(LogLevel)
Changes LogLevel for all sinks in the logger. No need to call UpdateMinimalLogLevelAcrossAllSinks() after this. 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 FlushAll()>
Declaration
public void SetMinimalLogLevelAcrossAllSinks(LogLevel newLogLevel)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | 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 FlushAll()>
Declaration
public void UpdateMinimalLogLevelAcrossAllSinks()