Class LoggerManager
Manager of the loggers. Usually shouldn't be accessed directly, but via codegenerated Log. calls.
Namespace: Unity.Logging.Internal
Syntax
public static class LoggerManager : object
Properties
CurrentLoggerHandle
Currently active logger's handle. Log.Info(...) and other calls will go to this one. Used by codegen
Declaration
public static LoggerHandle CurrentLoggerHandle { get; }
Property Value
Type | Description |
---|---|
LoggerHandle |
Logger
Gets/Sets the current active logger. Log.Info(...) and other calls will go to this one. Used by codegen. User sees it as Log.Logger = ...
Declaration
public static Logger Logger { get; set; }
Property Value
Type | Description |
---|---|
Logger |
Methods
AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)
Adds global Function-based Decorator. Used by the codegen RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)
Declaration
public static void AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler> func)
Parameters
Type | Name | Description |
---|---|---|
FunctionPointer<LoggerManager.OutputWriterDecorateHandler> | func | Function-based Decorator to add |
AssertNoLocks()
Debug function to assert that there is no locks currently held on Unity.Logging.Internal.LogControllerWrapper
Declaration
public static void AssertNoLocks()
BeginEditDecoratePayloadHandles(out Int32)
Provides a list of global constant decorations. EndEditDecoratePayloadHandles(Int32) must be called afterwards. Used by the codegen
Declaration
public static ref FixedList4096Bytes<PayloadHandle> BeginEditDecoratePayloadHandles(out int nBefore)
Parameters
Type | Name | Description |
---|---|---|
Int32 | nBefore | Current count of list of global constant decorations |
Returns
Type | Description |
---|---|
FixedList4096Bytes<PayloadHandle> | The list of global constant decorations |
CallForEveryLogger(Action<Logger>)
Calls an action for every existing logger. OnNewLoggerCreated(Action<Logger>)
Declaration
public static void CallForEveryLogger(Action<Logger> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<Logger> | callback | Action to execute on all existing loggers |
ClearOnNewLoggerCreatedEvent()
Clears OnNewLoggerCreated(Action<Logger>) event subscribers list. OnNewLoggerCreated(Action<Logger>)
Declaration
public static void ClearOnNewLoggerCreatedEvent()
CompleteUpdateLoggers()
Completes previously scheduled ScheduleUpdateLoggers(JobHandle)
Declaration
public static void CompleteUpdateLoggers()
DebugPrintQueueInfos()
Declaration
public static void DebugPrintQueueInfos()
DeleteAllLoggers()
Calls FlushAll() and completes all in-flight ScheduleUpdateLoggers(JobHandle). Shutdowns all loggers and makes sure their state were valid.
Declaration
public static void DeleteAllLoggers()
EndEditDecoratePayloadHandles(Int32)
Call after BeginEditDecoratePayloadHandles(out Int32) is done Used by the codegen
Declaration
public static FixedList64Bytes<PayloadHandle> EndEditDecoratePayloadHandles(int nBefore)
Parameters
Type | Name | Description |
---|---|---|
Int32 | nBefore | nBefore from BeginEditDecoratePayloadHandles(out Int32) |
Returns
Type | Description |
---|---|
FixedList64Bytes<PayloadHandle> | The list of added handles during Begin-End scope |
FlushAll()
Call ScheduleUpdateLoggers(JobHandle) two times (because of double-buffering) and CompleteUpdateLoggers() to make sure all logs were processed.
Declaration
public static void FlushAll()
GetGlobalDecoratorMemoryManager()
Get global decorator's LogMemoryManager Used by the codegen
Declaration
public static ref LogMemoryManager GetGlobalDecoratorMemoryManager()
Returns
Type | Description |
---|---|
LogMemoryManager | Global decorator's LogMemoryManager |
GetLogger(in LoggerHandle)
Gets logger by its LoggerHandle
Declaration
public static Logger GetLogger(in LoggerHandle loggerHandle)
Parameters
Type | Name | Description |
---|---|---|
LoggerHandle | loggerHandle | Handle |
Returns
Type | Description |
---|---|
Logger | Logger that has the handle |
GetTotalDispatchedMessages()
Debug function to get all currently dispatched messages across all loggers
Declaration
public static int GetTotalDispatchedMessages()
Returns
Type | Description |
---|---|
Int32 | Number of all currently dispatched messages across all loggers |
GlobalDecorateHandlerCount()
Returns count of global Function-based Decorators (that you can add with Log.Decorate(function) or AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>) and remove with RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)) They will be executed each time log message is created for any Logger
Declaration
public static int GlobalDecorateHandlerCount()
Returns
Type | Description |
---|---|
Int32 | Count of global Function-based Decorators |
GlobalDecoratePayloadsCount()
Returns count of global constant Decorators (that you can add with Log.Decorate("name", value)) They will be copied to new log message payload each time log message is created for any logger
Declaration
public static int GlobalDecoratePayloadsCount()
Returns
Type | Description |
---|---|
Int32 | Count of global constant Decorators |
OnNewLoggerCreated(Action<Logger>)
Adds an action to call on any new logger creation CallForEveryLogger(Action<Logger>)
Declaration
public static void OnNewLoggerCreated(Action<Logger> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<Logger> | callback | Action to execute on any new logger |
ReleaseDecoratePayloadBufferDeferred(LoggerHandle, FixedList64Bytes<PayloadHandle>)
When the decorator is not active anymore - resources should be freed. This method calls ReleasePayloadBufferDeferred and removes the payloads from decor list
Declaration
public static void ReleaseDecoratePayloadBufferDeferred(LoggerHandle handle, FixedList64Bytes<PayloadHandle> payloadHandles)
Parameters
Type | Name | Description |
---|---|---|
LoggerHandle | handle | LoggerHandle to get the LogController. Global if not valid |
FixedList64Bytes<PayloadHandle> | payloadHandles | Payload to release in 2 frames |
RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)
Removes global Function-based Decorator. Used by the codegen AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)
Declaration
public static void RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler> func)
Parameters
Type | Name | Description |
---|---|---|
FunctionPointer<LoggerManager.OutputWriterDecorateHandler> | func | Function-based Decorator to remove |
ScheduleUpdateLoggers(JobHandle)
Schedules Update jobs for all loggers on a worker thread. If another ScheduleUpdateLoggers(JobHandle) is in progress - will add its JobHandle as a dependency.
Declaration
public static JobHandle ScheduleUpdateLoggers(JobHandle dependency = null)
Parameters
Type | Name | Description |
---|---|---|
JobHandle | dependency | Dependencies are used to ensure that a job executes on worker threads after the dependency has completed execution. Please, make sure that two jobs that read or write to the same data don't run in parallel. |
Returns
Type | Description |
---|---|
JobHandle | The handle identifying the scheduled job. Can be used as a dependency for a later job or ensure completion on the main thread. |