pycarol.logger

Logger Handler integrated with Carol.

class pycarol.logger.CarolHandler(carol: Optional[Carol] = None, task_id: Optional[str] = None)[source]

Carol logger handler.

This class can be used to log information in long tasks in Carol.

Parameters
  • carol – Carol object.

  • task_id – Task id.

Usage:

from pycarol import Carol, CarolHandler
import logging
logger = logging.getLogger(__name__)
carol = CarolHandler(Carol())
carol.setLevel(logging.INFO)
logger.addHandler(carol)

# This will not be logged in Carol. Level is set to INFO
logger.debug('This is a debug message')
logger.info('This is an info message')
logger.warning('This is a warning message')
logger.error('This is an error message')
logger.critical('This is a critical message')

# These methods will use the current long task id provided by Carol when running
# your application.
# For local environments you need to set that manually first on the beginning of
# your code:

import os
os.environ['LONGTASKID'] = TASK_ID

If no TASK ID is passed it works as a Console Handler.

emit(record) None[source]

Log the message.

Parameters

recordstr Message to log.