-
public class DittoLoggerSingleton object 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.enabled 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.exportToFile for further details on locally collected logs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classDittoLogger.InternalDittoLogger
-
Field Summary
Fields Modifier and Type Field Description private static BooleanemojiLogLevelHeadingsEnabledprivate static Booleanenabledprivate static DittoLogLevelminimumLogLevelpublic final static DittoLoggerINSTANCE
-
Method Summary
Modifier and Type Method Description final static BigIntegerexportToFile(String path)Exports collected logs to a compressed and JSON-encoded file on the local file system. final static UnitsetLogFile(String logFile)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). final UnitsetCustomLogCallback(Function2<DittoLogLevel, String, Unit> logCallback)Registers a callback for a fully customizable way of handling log "events" from the logger (on top of logging to the console, and to a file, if any). final static UnitsetCustomLogCallback(DittoLogCallback logCb)Registers a callback for a fully customizable way of handling log "events" from the logger (on top of logging to the console, and to a file, if any). final static UnitunsetCustomLogCallback()Unregisters the currently registered callback (if any), to be used when interacting with the SDK from Java. final UnitffiCustomLog(CLogLevel_t cLogLevel, String msg)Sends a single message to the log at the given log level. final static BooleangetEmojiLogLevelHeadingsEnabled()final static UnitsetEmojiLogLevelHeadingsEnabled(Boolean emojiLogLevelHeadingsEnabled)final static BooleangetEnabled()final static UnitsetEnabled(Boolean enabled)final static DittoLogLevelgetMinimumLogLevel()final static UnitsetMinimumLogLevel(DittoLogLevel minimumLogLevel)-
-
Method Detail
-
exportToFile
final static BigInteger exportToFile(String path)
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 enabled setting and the configured 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.
For more granular exception handling check the DittoError.IoErrorReason subtypes:
- Parameters:
path- The path of the file to write the logs to.
-
setLogFile
final static Unit setLogFile(String logFile)
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).
- Parameters:
logFile- can benil, in which case the current logging file, if any, is unregistered, otherwise, the file path must be within an already existing directory.
-
setCustomLogCallback
final Unit setCustomLogCallback(Function2<DittoLogLevel, String, Unit> logCallback)
Registers a callback for a fully customizable way of handling log "events" from the logger (on top of logging to the console, and to a file, if any).
- Parameters:
logCallback- a callback that can benull, in which case the current callback, if any, is unregistered.
-
setCustomLogCallback
final static Unit setCustomLogCallback(DittoLogCallback logCb)
Registers a callback for a fully customizable way of handling log "events" from the logger (on top of logging to the console, and to a file, if any).
Version to be used when interacting with the SDK from Java.
- Parameters:
logCb- a callback that can't benull.
-
unsetCustomLogCallback
final static Unit unsetCustomLogCallback()
Unregisters the currently registered callback (if any), to be used when interacting with the SDK from Java.
-
ffiCustomLog
final Unit ffiCustomLog(CLogLevel_t cLogLevel, String msg)
Sends a single message to the log at the given log level.
- Parameters:
cLogLevel- The log level to send the message at.msg- The message to send.
-
getEmojiLogLevelHeadingsEnabled
final static Boolean getEmojiLogLevelHeadingsEnabled()
-
setEmojiLogLevelHeadingsEnabled
final static Unit setEmojiLogLevelHeadingsEnabled(Boolean emojiLogLevelHeadingsEnabled)
-
getEnabled
final static Boolean getEnabled()
-
setEnabled
final static Unit setEnabled(Boolean enabled)
-
getMinimumLogLevel
final static DittoLogLevel getMinimumLogLevel()
-
setMinimumLogLevel
final static Unit setMinimumLogLevel(DittoLogLevel minimumLogLevel)
-
-
-
-