gigl.common.logger#

Classes#

Logger

GiGL's custom logger class used for local and cloud logging (VertexAI, Dataflow, etc.)

Module Contents#

class gigl.common.logger.Logger(logger=None, name=None, log_to_file=False, extra=None)[source]#

Bases: logging.LoggerAdapter

GiGL’s custom logger class used for local and cloud logging (VertexAI, Dataflow, etc.) :param logger: A custom logger to use. If not provided, the default logger will be created. :type logger: Optional[logging.Logger] :param name: The name to be used for the logger. By default uses “root”. :type name: Optional[str] :param log_to_file: If True, logs will be written to a file. If False, logs will be written to the console. :type log_to_file: bool :param extra: Extra information to be added to the log message. :type extra: Optional[Dict[str, Any]]

Initialize the adapter with a logger and a dict-like object which provides contextual information. This constructor signature allows easy stacking of LoggerAdapters, if so desired.

You can effectively pass keyword arguments as shown in the following example:

adapter = LoggerAdapter(someLogger, dict(p1=v1, p2=”v2”))

Parameters:
  • logger (Optional[logging.Logger])

  • name (Optional[str])

  • log_to_file (bool)

  • extra (Optional[Dict[str, Any]])

process(msg, kwargs)[source]#

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.

Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.

Parameters:
  • msg (str)

  • kwargs (MutableMapping[str, Any])

Return type:

Any