Class Logger
A buffered text logger that serializes objects as JSON and writes them to disk via ChunkedStream.
Implements
Inherited Members
Namespace: Unity.SimulationPro
Assembly: Unity.SimulationPro.Capture.dll
Syntax
public class Logger : BaseLogger, IDisposable
Remarks
Data is accumulated in memory until the buffer reaches bufferSize kilobytes or the elapsed time since the last flush exceeds the configured maximum, at which point the buffer is flushed asynchronously to a sequenced output file.
Constructors
Logger(string, int, int, string, LoggerSuffixOption, Func<string>)
Initializes a new instance of DataCapture logger with given params.
Declaration
public Logger(string logName, int bufferSize = 8192, int maxElapsedSeconds = 5, string userPath = "", LoggerSuffixOption suffixOption = LoggerSuffixOption.SEQ_NO, Func<string> customSuffix = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | logName | Name of the DataCapture Log file. |
| int | bufferSize | This corresponds to the file size (in KB). Default is set to 8192. |
| int | maxElapsedSeconds | Maximum elapsed time in seconds for the interpolation step. |
| string | userPath | Location of the log file. Default is set to Application persistent path. |
| LoggerSuffixOption | suffixOption | Option controlling the suffix appended to generated type names. |
| Func<string> | customSuffix | Custom suffix string to append to generated type names. |
Properties
bufferSize
Gets or sets the buffer size in kilobytes. When the accumulated data reaches this size, the buffer is flushed to disk.
Declaration
public int bufferSize { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Dispose()
Disposes the logger and unsubscribes from Manager tick events.
Declaration
public void Dispose()
Flushall(bool)
Flush data in the buffer to the file system right away. Usually it waits till the size of the buffer reaches to the bufferSize set.
Declaration
public void Flushall(bool synchronous = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | synchronous | Whether data collection should be performed synchronously. |
Log(object)
Logs the data to the file by appending it to the current buffer.
Declaration
public void Log(object parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| object | parameters | Serializable struct containing data to be captured. |