Struct LogWriterUtils
Parser logic
Inherited Members
Namespace: Unity.Logging
Assembly: Unity.Logging.dll
Syntax
[BurstCompile]
public struct LogWriterUtils
Methods
AddDecorateHandler(LogControllerScopedLock, OutputWriterDecorateHandler, bool)
Used by Log.To().Decorate calls to add a method that's called for every log message, and adds decorations to it for a particular logger.
Declaration
public static LogDecorateHandlerScope AddDecorateHandler(LogControllerScopedLock @lock, LoggerManager.OutputWriterDecorateHandler handler, bool isBurstable = false)
Parameters
Type | Name | Description |
---|---|---|
LogControllerScopedLock | lock | LogControllerScopedLock of logger that adds the decorator |
LoggerManager.OutputWriterDecorateHandler | handler | Decorate call delegate |
bool | isBurstable | If true - |
Returns
Type | Description |
---|---|
LogDecorateHandlerScope | LogDecorateHandlerScope scoped struct |
AddDecorateHandler(OutputWriterDecorateHandler, bool)
Used by Log.Decorate calls to add a method that's called for every log message, and add decorations to it globally.
Declaration
public static LogDecorateHandlerScope AddDecorateHandler(LoggerManager.OutputWriterDecorateHandler handler, bool isBurstable = false)
Parameters
Type | Name | Description |
---|---|---|
LoggerManager.OutputWriterDecorateHandler | handler | Decorate call delegate |
bool | isBurstable | If true - |
Returns
Type | Description |
---|---|
LogDecorateHandlerScope | LogDecorateHandlerScope scoped struct |
AddOutputHandler(OutputWriterHandler, bool)
Adds a delegate to process and generate logging output strings for a set of context structs.
Declaration
public static IntPtr AddOutputHandler(LogWriterUtils.OutputWriterHandler handler, bool isBurstable = false)
Parameters
Type | Name | Description |
---|---|---|
LogWriterUtils.OutputWriterHandler | handler | LogWriterUtils.OutputWriterHandler delegate to output logging context struct data. |
bool | isBurstable | True to Burst compile the handler and false if it's not Burst compatible. |
Returns
Type | Description |
---|---|
IntPtr | A token referencing this handler, used for removing the handler later. |
Remarks
This method is invoked by source generated code and generally shouldn't be used directly.
Since this method takes a delegate parameter, it's not Burst compatible itself. However, the method referenced by the delegate can be Burst compatible or not, depending on how it's implemented. If the handler method is Burst compatible, then pass true for isBurstable to Burst compile the handler, otherwise the handler always runs as managed code.
RemoveOutputHandler(IntPtr)
Removes an LogWriterUtils.OutputWriterHandler delegate from the parser.
Declaration
public static void RemoveOutputHandler(IntPtr token)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | token | Value returned by a previous call to AddOutputHandler(OutputWriterHandler, bool) for the handler to remove. |
Remarks
This method is invoked by source generated code and generally shouldn't be used directly.
Once the handler is removed, context structs this handler serviced will no longer generated logging output. Log message that reference these context structs will still be outputted, but the context data will be missing.
SetOutputHandlerForLevel(OutputWriterLevelHandler, bool)
Sets a delegate to process and generate logging output strings for LogLevel.
Declaration
public static void SetOutputHandlerForLevel(LogWriterUtils.OutputWriterLevelHandler handler, bool isBurstable = false)
Parameters
Type | Name | Description |
---|---|---|
LogWriterUtils.OutputWriterLevelHandler | handler | LogWriterUtils.OutputWriterLevelHandler delegate to output logging for LogLevel. |
bool | isBurstable | True to Burst compile the handler and false if it's not Burst compatible. |
Remarks
This method is invoked by source generated code and generally shouldn't be used directly.
Since this method takes a delegate parameter, it's not Burst compatible itself. However, the method referenced by the delegate can be Burst compatible or not, depending on how it's implemented. If the handler method is Burst compatible, then pass true for isBurstable to Burst compile the handler, otherwise the handler always runs as managed code.
SetOutputHandlerForTimestamp(OutputWriterTimestampHandler, bool)
Sets a delegate to process and generate logging output strings for timestamps.
Declaration
public static void SetOutputHandlerForTimestamp(LogWriterUtils.OutputWriterTimestampHandler handler, bool isBurstable = false)
Parameters
Type | Name | Description |
---|---|---|
LogWriterUtils.OutputWriterTimestampHandler | handler | LogWriterUtils.OutputWriterTimestampHandler delegate to output logging for timestamps. |
bool | isBurstable | True to Burst compile the handler and false if it's not Burst compatible. |
Remarks
This method is invoked by source generated code and generally shouldn't be used directly.
Since this method takes a delegate parameter, it's not Burst compatible itself. However, the method referenced by the delegate can be Burst compatible or not, depending on how it's implemented. If the handler method is Burst compatible, then pass true for isBurstable to Burst compile the handler, otherwise the handler always runs as managed code.
WriteFormattedContextData(ref FormatterStruct, in PayloadHandle, ref UnsafeText, ref FixedString512Bytes, ref LogMemoryManager, ref ArgumentInfo)
Appends string representation of a binary data in the payload
Declaration
public static bool WriteFormattedContextData(ref FormatterStruct formatter, in PayloadHandle payload, ref UnsafeText messageOutput, ref FixedString512Bytes errorMessage, ref LogMemoryManager memAllocator, ref ArgumentInfo currArgSlot)
Parameters
Type | Name | Description |
---|---|---|
FormatterStruct | formatter | Current formatter |
PayloadHandle | payload | PayloadHandle that points to the binary data |
UnsafeText | messageOutput | UnsafeText where to append |
FixedString512Bytes | errorMessage | Returns an error message string, should a problem parsing the message occur. |
LogMemoryManager | memAllocator | Memory manager that holds binary representation of the mirror struct |
ArgumentInfo | currArgSlot | Hole that was used to describe the struct in the log message, for instance |
Returns
Type | Description |
---|---|
bool | True on success |
WriteFormattedLevel(LogLevel, ref UnsafeText)
Appends string representation of LogLevel into Unity.Collections.LowLevel.Unsafe.UnsafeText
Declaration
public static bool WriteFormattedLevel(LogLevel level, ref UnsafeText messageOutput)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | Level to append |
UnsafeText | messageOutput | Where to append |
Returns
Type | Description |
---|---|
bool | True on success |
WriteFormattedTimestamp(in long, ref UnsafeText)
Writes Timestamp to the UnsafeText as UTC
Declaration
public static bool WriteFormattedTimestamp(in long timestamp, ref UnsafeText messageOutput)
Parameters
Type | Name | Description |
---|---|---|
long | timestamp | Timestamp to write |
UnsafeText | messageOutput | Where to write to |
Returns
Type | Description |
---|---|
bool | True on success |
WriteFormattedTimestampLocalTimeZone(in long, ref UnsafeText)
Writes Timestamp to the UnsafeText in Local time zone
Declaration
public static bool WriteFormattedTimestampLocalTimeZone(in long timestamp, ref UnsafeText messageOutput)
Parameters
Type | Name | Description |
---|---|---|
long | timestamp | Timestamp to write |
UnsafeText | messageOutput | Where to write to |
Returns
Type | Description |
---|---|
bool | True on success |
WriteFormattedTimestampLocalTimeZoneForConsole(in long, ref UnsafeText)
Writes Timestamp to the UnsafeText in Local time zone to show in the Console Window in the Editor (HH:MM:SS)
Declaration
public static bool WriteFormattedTimestampLocalTimeZoneForConsole(in long timestamp, ref UnsafeText messageOutput)
Parameters
Type | Name | Description |
---|---|---|
long | timestamp | Timestamp to write |
UnsafeText | messageOutput | Where to write to |
Returns
Type | Description |
---|---|
bool | True on success |
WriteNewLine(ref UnsafeText)
Appends a new line into the Unity.Collections.LowLevel.Unsafe.UnsafeText
Declaration
public static bool WriteNewLine(ref UnsafeText messageOutput)
Parameters
Type | Name | Description |
---|---|---|
UnsafeText | messageOutput | UnsafeText to append the new line |
Returns
Type | Description |
---|---|
bool | True on success |
WriteProperties(ref UnsafeText)
Appends all properties into the Unity.Collections.LowLevel.Unsafe.UnsafeText. For now not implemented
Declaration
public static bool WriteProperties(ref UnsafeText messageOutput)
Parameters
Type | Name | Description |
---|---|---|
UnsafeText | messageOutput | UnsafeText to append the new line |
Returns
Type | Description |
---|---|
bool | True on success |