-
Notifications
You must be signed in to change notification settings - Fork 51
Logging
$ RUST_LOG="debug" codechain
$ RUST_LOG="tx=trace,sync=info" codechain
CodeChain has five log level, error, warn, info, debug and trace.
The error
level represents the event something can be dangerous, but it can still run. In the case that cannot run anymore, it must crash ASAP instead of logging.
The warn
level represents the event that is potentially dangerous.
The info
level represents the event that is not dangerous, but it's useful to know for users.
The debug
level represents the event that is useful for developers not for users.
CodeChain has the macro for designated log targets, cerror
, cwarn
, cinfo
, cdebug
and ctrace
.
These macros are designed for the designated targets.
The available targets are described in log_target. You must add a new mapping to add a new target.
(TARGET_ID_IN_CODE) => {
"target_name_in_logger"
};
The TARGET_ID_IN_CODE
is the identifier that will be used by macros. If you add the mapping as above, you can use the logging macro like cwarn(TARGET_ID_IN_CODE, "message to be logged");
.