rewind 0.2.0
rewind: ^0.2.0 copied to clipboard
A logging tool that enables you to record any data, with full customization of what is captured and the appearance of your logs at every logging level.
Rewind #
rewind
is a logging tool that enables you to record any data, with full customization of what is captured and the appearance of your logs at every logging level.
click here for an example output.
How To Use #
// log info
Log.i(object)
// log warning with additional message
Log.w(object, append: "Some more information.")
// log error overriding the string verion of the object
Log.e(object, override: "Use this instead.")
Levels #
See here for when to use each:
t
: traced
: debugi
: infow
: warninge
: errorf
: fatal
How To Configure #
Log Level
Log.level = Level.trace;
Composing Log Level Configs
// config for all not set
Log.defaultLogConfig = LogLevelConfig.def(
printer: SimplePrinter()
);
Log.warningLogConfig = LogLevelConfig.def(
printer: PrettyPrinter()
);
Log.errorLogConfig = LogLevelConfig(
printer: PrettyPrinter(),
// the number of frames to keep if a stacktrace is present.
framesToKeep: 10,
// components to be a part of the log
components: [
ObjectTypeComponent(),
StringifiedComponent(),
AppendLogComponent(),
IdComponent(),
TimeComponent(),
LogPointComponent(),
]);
You can create your own custom components
by extends the LogComponent
class.
Selecting The Output
By default the output goes to the console. But you can change it for example with:
Log.output = FileOutput(file: File("path/to/file"), overrideExisting: true, encoding: utf8);
Suported Outputs
- Console
- File
- Memory
- Stream
- Multiple (combines any of the above)
Logging Guidelines #
Ever wonder what level to log at? Follow the flow chart below. [Logging Guidelines]
anyhow #
rewind
is aware of types from the anyhow package. Therefore, when setting framesToKeep
, rewind will adjust the stack trace display accordingly.
Example Ouput #
Multiple Components
[Multiple Components]
Single Component
[Stringified Only Pretty]
Single Component Simple Print
[Stringified Only Simple]