Logging API

Used internally to handle log messages by the other TGDB Python API modules

class tgdb.log.TGLevel(value)

The level of debugging, including at what level a log should be recorded.

Renamed to more closely resemble the TGDB scheme. From 12/01/2019, transition all references to TGL* from current.

class tgdb.log.TGLogComponent(value)

This enumeration is for any components of the server that a user may want to keep track of.

They are broken down by larger components, and individual portions can be invoked for fine-grained control, or an aggregate one may be preferential. This class allows both of those possibilities.

Only intended when setting the loglevel on the server or the administrative client. The bits property and the aggregate_bits method are not intended for use in client code.

classmethod aggregate_bits(arr: Iterable)int

Gets the bit representation of the TGLogComponents in the iterable so that it may be sent to the server.

Not intended for client use.

Returns

A bit string (packed as a Python int) that contains all of the ‘on’ components.

property bits

Gets the bit representation of this TGLogComponent so that it may be sent to the server.

Not intended for client use.

Returns

A bit string (packed as a Python int) that contains all of the ‘on’ components.

class tgdb.log.TGLogManager

Class intended to initialize and start the logger.

classmethod getLogger()tgdb.log.TGLogger

Gets the logger (creating one if one does not already exist).

classmethod setLogger(logger: tgdb.log.TGLogger, setGlobal: bool = False)tgdb.log.TGLogger

Sets the logger, returning the old one.

class tgdb.log.TGLogger

Represents a single logger for the client to use to record information.

classmethod getBestLogCompFromStackTrace(trace: Union[traceback.StackSummary, List[inspect.FrameInfo]])

Only for internal use by the Python API/Admin Console

abstract isEnabled(level: tgdb.log.TGLevel)bool

Checks if a particular log level is enabled on this logger.

abstract property level

Gets this logger’s general log level.

abstract log(level: tgdb.log.TGLevel, fmt: str, *args, **kwargs)

Logs some piece of information.

Parameters

level – the level at which this logger should activate (for example, if the logging level is set to info,

then all info, warning, error, and fatal logs will be recorded, but debug logs will not be. :param fmt: the format string, similar to the format string for C’s printf. :param args: list of objects to pass into the formatted string. :param kwargs: dictionary of keyword arguments to pass into the formatted string.

abstract logEntity(level: tgdb.log.TGLevel, ent: tgdb.model.TGEntity)

Logs an entity at the particular log level.

abstract logException(level, msg, e: BaseException)

Logs an exception with a message. :param level:

abstract setLevel(lvl: tgdb.log.TGLevel, lc: tgdb.log.TGPyLogComponent)

Sets this logger’s level for the specific log component specified

class tgdb.log.TGPyLogCompManager(level: tgdb.log.TGLevel)

Only for internal use by the Python API/Admin Console

class tgdb.log.TGPyLogComponent(value)

This class represents logging inside of the Python API and the TGDB Admin Console. Only intended to set the loglevel on specific components when running into an error.

property displayName

The fancy display name used in the admin console or when lazily setting the level of a particular component using the API.

classmethod getBestMatch(filename: str)

Gets the best match for the corresponding filename, not for use by clients.