Skip to content

Logging System

The CCAT_LOG_LEVEL environment variable is used to manage the default logging level of the Cat. Take a look at Cat's environment variable here.

The available values for level are:

  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • CRITICAL

Logging messages which are less severe than level will be ignored; logging messages which have severity level or higher will be emitted to the console.

How to

The logging system can be imported like this

from cat.log import log

and then used as easy as:

log.error("A simple text here")
log.info(f"Value of user message is {user_message_json["text"]}")
log.critical(variable_value)

Take a look here if you want to better understand how the log system is implemented.

Examples

Follows an example of the console log for each log level.

DEBUG

  • what you write in the code:

    log.debug(f'user message: {user_message_json["text"]}')
    
  • what the console logs:

    cheshire_cat_core | [2024-01-20 17:40:23.816] DEBUG cat.plugins.cat-formatter.cat_formatter..before_cat_reads_message::26 => 'user message: The answer to all questions is 42.'

INFO

  • what you write in the code:

    log.info(f'user message: {user_message_json["text"]}')
    
  • what the console logs:

    cheshire_cat_core | [2024-01-20 17:42:19.609] INFO cat.plugins.cat-formatter.cat_formatter..before_cat_reads_message::26 => 'user message: The answer to all questions is 42.'

WARNING

  • what you write in the code:

    log.warning(f'user message: {user_message_json["text"]}')
    
  • what the console logs:

    cheshire_cat_core | [2024-01-20 17:59:05.336] WARNING cat.plugins.cat-formatter.cat_formatter..before_cat_reads_message::26 => 'user message: The answer to all questions is 42.'

ERROR

  • what you write in the code:

    log.error(f'user message: {user_message_json["text"]}')
    
  • what the console logs:

    cheshire_cat_core | [2024-01-20 18:08:06.412] ERROR cat.plugins.cat-formatter.cat_formatter..before_cat_reads_message::26 => 'user message: The answer to all questions is 42.'

CRITICAL

  • what you write in the code:

    log.critical(f'user message: {user_message_json["text"]}')
    
  • what the console logs:

    cheshire_cat_core | [2024-01-20 18:11:24.992] CRITICAL cat.plugins.cat-formatter.cat_formatter..before_cat_reads_message::26 => 'user message: The answer to all questions is 42.'