ID EN
Logging

LogRecord

Python 3.11 🇮🇩 Bahasa Indonesia

Berisi semua informasi yang berkaitan dengan peristiwa yang sedang dicatat.

Syntax

PYTHON
class logging.LogRecord(name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None)

Arguments

Parameter Deskripsi
name The name of the logger used to log the event represented by this LogRecord. Note that the logger name in the LogRecord will always have this value, even though it may be emitted by a handler attached to a different (ancestor) logger.
name The name of the logger used to log the event represented by this LogRecord. Note that the logger name in the LogRecord will always have this value, even though it may be emitted by a handler attached to a different (ancestor) logger.
level The numeric level of the logging event (such as 10 for DEBUG, 20 for INFO, etc). Note that this is converted to two attributes of the LogRecord: levelno for the numeric value and levelname for the corresponding level name.
level The numeric level of the logging event (such as 10 for DEBUG, 20 for INFO, etc). Note that this is converted to two attributes of the LogRecord: levelno for the numeric value and levelname for the corresponding level name.
pathname The full string path of the source file where the logging call was made.
pathname The full string path of the source file where the logging call was made.
lineno The line number in the source file where the logging call was made.
lineno The line number in the source file where the logging call was made.
msg The event description message, which can be a %-format string with placeholders for variable data, or an arbitrary object (see Using arbitrary objects as messages).
msg The event description message, which can be a %-format string with placeholders for variable data, or an arbitrary object (see Using arbitrary objects as messages).
args Variable data to merge into the msg argument to obtain the event description.
args Variable data to merge into the msg argument to obtain the event description.
exc_info An exception tuple with the current exception information, as returned by sys.exc_info(), or None if no exception information is available.
exc_info An exception tuple with the current exception information, as returned by sys.exc_info(), or None if no exception information is available.
func The name of the function or method from which the logging call was invoked.

Contoh

Example 1
PYTHON
old_factory = logging.getLogRecordFactory()

def record_factory(*args, **kwargs):
    record = old_factory(*args, **kwargs)
    record.custom_attribute = 0xdecafbad
    return record

logging.setLogRecordFactory(record_factory)

See Also

str int numeric level str int Any Using arbitrary objects as messages tuple