Static
customReturns the current custom log callback, undefined
by default. See
setCustomLogCallback() for a detailed
description.
Static
emojiRepresents whether or not emojis should be used as the log level indicator in the logs.
Represents whether or not emojis should be used as the log level indicator in the logs.
Static
enabledWhether the logger is currently enabled.
Logs exported through exportToFile() are not
affected by this setting and will also include logs emitted while
enabled is false
.
Enables or disables logging.
Static
logRegisters 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
minimumThe minimum log level at which logs will be logged.
For example if this is set to Warning
, then only logs that are logged
with the Warning
or Error
log levels will be shown.
Logs exported through exportToFile() are not
affected by this setting and include all logs at Debug
level and above.
The minimum log level at which logs will be logged.
For example if this is set to Warning
, then only logs that are logged
with the Warning
or Error
log levels will be shown.
Static
debugStatic
errorStatic
exportExports collected logs to a compressed and JSON-encoded file on the local file system.
Ditto's logger locally collects a limited amount of logs at Debug
level
and above, periodically discarding older logs. This internal logger is
always enabled and works independently of the Logger.enabled
setting and the configured Logger.minimumLogLevel. 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 path 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.
Not supported in browser environments.
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 path
to have the .jsonl.gz
file extension but Ditto won't
enforce it, nor correct it.
The number of bytes written to the file.
TypeError
if path
is not a string.
DittoError io/*
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.
DittoError sdk/unsupported
when called in a browser
environment.
Static
infoStatic
logLogs the message for the given level
.
Static
setRegisters a custom callback that will be called to report each log entry.
Optional
callback: CustomLogCallbackfunction called for each log entry. undefined
will
unregister any previous callback and stop reporting log entries through
callbacks.
if callback
is not a function or undefined
.
if called in a React Native environment.
Static
setOn Node, 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). In the browser, this method has no effect.
can be null
, in which case the current logging file, if any,
is unregistered, otherwise, the file path must be within an already
existing directory.
Static
setConvenience method, takes the path part of the URL and calls setLogFile() with it.
Static
verboseStatic
warning
Class with static methods to customize the logging behavior from Ditto and log messages with the Ditto logging infrastructure.
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 closed. If this is a concern, consider either disabling logging by setting Logger.enabled to
false
, or instantiating a new Ditto instance. After either of these actions, it is safe to remove the persistence directory. Please refer toexportToFile()
for further details on locally collected logs.