langtest.logger.Logger#

class Logger(name='langtest', log_dir=None, level=20, max_bytes=10485760, backup_count=5)#

Bases: object

A class to configure a logger with a File Handler.

__init__(name='langtest', log_dir=None, level=20, max_bytes=10485760, backup_count=5)#

Initialize and configure a logger using a File Handler.

Parameters:
  • name (str) – The name of the logger.

  • log_dir (str) – The directory to store the log files.

  • level (int) – The log level.

  • max_bytes (int) – The maximum size of the log file in bytes. default is 10MB.

  • backup_count (int) – The number of backup log files to keep.

Methods

__init__([name, log_dir, level, max_bytes, ...])

Initialize and configure a logger using a File Handler.

add_console_handler([level])

Add a console handler to the logger.

get_logger()

Return the logger object.

remove_console_handler()

Remove the console handler from the logger.

remove_file_handler()

Remove the file handler from the logger.

set_level(level)

Set the log level of the logger.

add_console_handler(level=20)#

Add a console handler to the logger.

Parameters:

level (int) – The log level.

get_logger()#

Return the logger object.

Returns:

The logger object.

Return type:

logging.Logger

remove_console_handler()#

Remove the console handler from the logger.

remove_file_handler()#

Remove the file handler from the logger.

set_level(level)#

Set the log level of the logger.

Parameters:

level (int) – The log level.