gigl.common.Logger#

class gigl.common.logger.Logger(logger: Logger | None = None, name: str | None = None, log_to_file: bool = False, extra: Dict[str, Any] | None = None)#

Bases: LoggerAdapter

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

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

Methods

__init__

Initialize the adapter with a logger and a dict-like object which provides contextual information.

critical

Delegate a critical call to the underlying logger.

debug

Delegate a debug call to the underlying logger.

error

Delegate an error call to the underlying logger.

exception

Delegate an exception call to the underlying logger.

getEffectiveLevel

Get the effective level for the underlying logger.

hasHandlers

See if the underlying logger has any handlers.

info

Delegate an info call to the underlying logger.

isEnabledFor

Is this logger enabled for level 'level'?

log

Delegate a log call to the underlying logger, after adding contextual information from this adapter instance.

process

Process the logging message and keyword arguments passed in to a logging call to insert contextual information.

setLevel

Set the specified level on the underlying logger.

warn

warning

Delegate a warning call to the underlying logger.

__init__(logger: Logger | None = None, name: str | None = None, log_to_file: bool = False, extra: Dict[str, Any] | None = None)#

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”))

__repr__()#

Return repr(self).

__weakref__#

list of weak references to the object (if defined)

critical(msg, *args, **kwargs)#

Delegate a critical call to the underlying logger.

debug(msg, *args, **kwargs)#

Delegate a debug call to the underlying logger.

error(msg, *args, **kwargs)#

Delegate an error call to the underlying logger.

exception(msg, *args, exc_info=True, **kwargs)#

Delegate an exception call to the underlying logger.

getEffectiveLevel()#

Get the effective level for the underlying logger.

hasHandlers()#

See if the underlying logger has any handlers.

info(msg, *args, **kwargs)#

Delegate an info call to the underlying logger.

isEnabledFor(level)#

Is this logger enabled for level ‘level’?

log(level, msg, *args, **kwargs)#

Delegate a log call to the underlying logger, after adding contextual information from this adapter instance.

process(msg: str, kwargs: MutableMapping[str, Any]) Any#

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.

setLevel(level)#

Set the specified level on the underlying logger.

warning(msg, *args, **kwargs)#

Delegate a warning call to the underlying logger.