Class with static methods to customize the logging behavior from Ditto. More...
Static Public Member Functions | |
| static void | SetLoggingEnabled (bool enabled) |
| Enables or disables the logging mechanisms. | |
| static bool | GetLoggingEnabled () |
Returns true iff the logging mechanisms are enabled. | |
| static void | SetEmojiLogLevelHeadingsEnabled (bool enabled) |
| static bool | GetEmojiLogLevelHeadingsEnabled () |
| static void | SetMinimumLogLevel (DittoLogLevel log_level) |
Sets the minimum logging level to be printed in the console or stdout. For example if this is set to DittoLogLevel.Warning, then only logs that are logged with the Warning or Error log levels will be shown. | |
| static DittoLogLevel | GetMinimumLogLevel () |
Gets the last registered log_level. | |
| static void | SetLogFile (string log_file_path) |
| Registers a file path where logs will be written to, whenever Ditto wants to issue a log (on top of emitting the log to the console). | |
| static void | SetCustomLogCb (Action< DittoLogLevel, string > log_cb) |
| static async Task< ulong > | ExportToFileAsync (string path) |
| Exports collected logs to a compressed and JSON-encoded file on the local file system. | |
Class with static methods to customize the logging behavior from Ditto.
Currently, Ditto uses the persistence directory of the Ditto instance that was most recently created to store a limited amount of logs. Ditto may continue writing logs to a persistence directory even after the associated Ditto instance is deallocated. If this is a concern, consider either disabling logging by setting DittoLogger.SetLoggingEnabled(bool) to false, or instantiating a new Ditto instance. After either of these actions, it is safe to remove the persistence directory. Please refer to DittoLogger.ExportToFileAsync(string) for further details on locally collected logs.
|
inlinestatic |
Exports collected logs to a compressed and JSON-encoded file on the local file system.
DittoLogger locally collects a limited amount of logs at DittoLogLevel.Debug level and above, periodically discarding old logs. This internal logger is always enabled and works independently of the SetLoggingEnabled(bool) setting and the configured SetMinimumLogLevel(DittoLogLevel). Its logs can be requested and downloaded from any peer that is active in a Ditto app using the portal's device dashboard. This method provides an alternative way of accessing those logs by exporting them to the local file system.
The logs will be written as a gzip compressed file at the location specified by the path parameter. When uncompressed, the file contains one JSON value per line with the oldest entry on the first line (JSON lines format).
Ditto limits the amount of logs it retains on disk to 15 MB and a maximum age of three days. Older logs are periodically discarded once one of these limits is reached.
This method currently only exports logs from the most recently created Ditto instance, even when multiple instances are running in the same process.
| DittoIOException | When the file cannot be written to disk. Prevent this by ensuring that no file exists at the provided path, all parent directories exists, sufficient permissions are granted, and that the disk is not full. For more granular exception handling check its subtypes: |
| path | The path of the file to write the logs to. The file must not already exist, and the containing directory must exist. It is recommended for the file to have the .jsonl.gz file extension but Ditto won't enforce it, nor correct it. |
|
static |
Returns true iff the logging mechanisms are enabled.
|
static |
Gets the last registered log_level.
|
inlinestatic |
Registers a file path where logs will be written to, whenever Ditto wants to issue a log (on top of emitting the log to the console).
The path, if any, must be within an already existing directory.
If the log_file_path parameter is null, the current logging file, if any, is unregistered.
|
static |
Enables or disables the logging mechanisms.
Logs exported through ExportToFileAsync(string) are not affected by this setting and will also include logs emitted while enabled is false.
|
static |
Sets the minimum logging level to be printed in the console or stdout. For example if this is set to DittoLogLevel.Warning, then only logs that are logged with the Warning or Error log levels will be shown.
Logs exported through ExportToFileAsync(string) are not affected by this setting and include all logs at DittoLogLevel.Debug and above.