titanfe.log module¶
setup the logging with a custom metric-level
-
class
titanfe.log.
FlowContext
(flowuid: str = '', flowname: str = '', brickuid: str = '', brickname: str = '')[source]¶ Bases:
object
The Flow Context
-
brickname
: str = ''¶
-
brickuid
: str = ''¶
-
flowname
: str = ''¶
-
flowuid
: str = ''¶
-
-
class
titanfe.log.
KafkaLogHandler
(bootstrap_server, topic)[source]¶ Bases:
logging.Handler
Stream LogRecords to Kafka
- Parameters:
bootstrap_server (str) – ‘Host:Port’ of a kafka bootstrap server
topic (str) – the kafka topic to produce into
-
class
titanfe.log.
TitanLogAdapter
(logger, extra)[source]¶ Bases:
logging.LoggerAdapter
The Log Adapter wraps a logger and adds some context to each log record
-
property
context
¶
-
metric
(message, *args, **kwargs)¶
-
property
-
class
titanfe.log.
TitanLogRecord
(name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, **kwargs)[source]¶ Bases:
logging.LogRecord
A log record - Titan style
-
brickname
= ''¶
-
brickuid
= ''¶
-
flowname
= ''¶
-
flowuid
= ''¶
-
hostname
= 'build-19467538-project-510666-titanfe'¶
-
servicename
= ''¶
-
-
class
titanfe.log.
TitanPlatformLogger
(name, context: Optional[titanfe.log.FlowContext] = None)[source]¶ Bases:
logging.Logger
to write contextual logging information use e.g. log.with_context.info
-
getChild
(suffix) → titanfe.log.TitanPlatformLogger[source]¶ Get a logger which is a descendant to this one.
This is a convenience method, such that
logging.getLogger(‘abc’).getChild(‘def.ghi’)
is the same as
logging.getLogger(‘abc.def.ghi’)
It’s useful, for example, when the parent logger is named using __name__ rather than a literal string.
-
property
with_context
¶
-
-
class
titanfe.log.
UjoBinFormatter
(fmt=None, datefmt=None, style='%')[source]¶ Bases:
logging.Formatter
Format log records as an UjoBinary
-
titanfe.log.
add_logging_level
(level, level_name, method_name=None)[source]¶ add a level to the logging module
- Parameters:
level (int) – level number
level_name – name of the level
method_name – name of the method that gets attached to logging
-
titanfe.log.
flush_kafka_log_handler
()[source]¶ “Flush messages sent to KafkaLogHandler and suppress warnings from kafka –> called during shutdown of brick runner
-
titanfe.log.
getLogger
(name: str, context: Optional[titanfe.log.FlowContext] = None) → logging.Logger[source]¶ Get a Logger :param name: the logger name :param context: a flow context (if available)
- Returns:
a Logger
- Return type:
logging.Logger