Custom level of messages

Levels have an important role in the logging process. They are used for filtering the records by their priority. If you set the info level for the logger, it will skip all the debug and trace records. Obviously, you need more verbose logging for debugging purposes and less verbose logging to use the server in production.

Internally, every macro of the log crate uses the log! macro, which has an argument to set the level:

log!(Level::Error, "Error information: {}", error);

It takes an instance of the Level enumeration that has the following variants—Trace, Debug, Info, Warn, and Error.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.156.93