colossalai.logging

colossalai.logging.get_dist_logger(name='colossalai')

Get logger instance based on name. The DistributedLogger will create singleton instances, which means that only one logger instance is created per name.

Parameters

name (str) – name of the logger, name must be unique

Returns

a distributed logger instance

Return type

colossalai.logging.DistributedLogger

class colossalai.logging.DistributedLogger(name)

This is a distributed event logger class essentially based on logging.

Parameters

name (str) – The name of the logger

static get_instance(name)

Get the unique single logger instance based on name.

Parameters

name (str) – The name of the logger

Returns

A DistributedLogger object

Return type

DistributedLogger

set_level(level)

Set the logging level

Parameters

level (str) – Can only be INFO, DEBUG, WARNING and ERROR

log_to_file(path, mode='a', level='INFO', suffix=None)

Save the logs to file

Parameters
  • path (A string or pathlib.Path object) – The file to save the log

  • mode (str) – The mode to write log into the file

  • level (str) – Can only be INFO, DEBUG, WARNING and ERROR

  • suffix (str) – The suffix string of log’s name

info(message, parallel_mode=ParallelMode.GLOBAL, ranks=None)

Log an info message.

Parameters
warning(message, parallel_mode=ParallelMode.GLOBAL, ranks=None)

Log a warning message.

Parameters
debug(message, parallel_mode=ParallelMode.GLOBAL, ranks=None)

Log a debug message.

Parameters
error(message, parallel_mode=ParallelMode.GLOBAL, ranks=None)

Log an error message.

Parameters