Usage

Getting started

To log messages and data, we need to create two objects:

  1. A MessageLog, which stores a message and any associated data that we want to log.

  2. A CodenicLogger, which enables us to log the contents of a MessageLog in a formatted structure.

For example:

final codenicLogger = CodenicLogger();

final messageLog = MessageLog(
  id: 'test',
  message: 'Test message logged',
  data: { 'name': 'Revan', 'age': 27 },
);

codenicLogger.info(messageLog);

Different Log levels

The CodenicLogger offers multiple log levels, each with a different color to make them easier to spot in the console. This can help you quickly identify and locate important log messages.

Logging an Exception

To log an error together with its stack trace, you can pass it to the logger. This can help you troubleshoot and diagnose issues more effectively.

Setting a user ID

When a user ID is provided, it will automatically be included in the log data.

To remove the user ID, simply set it back to null:

Last updated