seqlog package¶
Module contents¶
-
seqlog.
configure_from_dict
(config, override_root_logger=True)[source]¶ Configure Seq logging using a dictionary.
Uses logging.config.dictConfig().
Parameters: - config (dict) – A dict containing the configuration.
- override_root_logger (bool) – Override the root logger to use a Seq-specific implementation? (default: True)
-
seqlog.
configure_from_file
(file_name, override_root_logger=True)[source]¶ Configure Seq logging using YAML-format configuration file.
Uses logging.config.dictConfig().
Parameters: - file_name (str) – The name of the configuration file to use.
- override_root_logger (bool) – Override the root logger to use a Seq-specific implementation? (default: True)
-
seqlog.
get_global_log_properties
()[source]¶ Get the properties to be added to all structured log entries.
Returns: A copy of the global log properties. Return type: dict
-
seqlog.
log_to_console
(level=30, override_root_logger=False, **kwargs)[source]¶ Configure the logging system to send log entries to the console.
Note that the root logger will not log to Seq by default.
Parameters: - level – The minimum level at which to log.
- override_root_logger – Override the root logger, too? Note - this might cause problems if third-party components try to be clever when using the logging.XXX functions.
-
seqlog.
log_to_seq
(server_url, api_key=None, level=30, batch_size=10, auto_flush_timeout=None, additional_handlers=None, override_root_logger=False, **kwargs)[source]¶ Configure the logging system to send log entries to Seq.
Note that the root logger will not log to Seq by default.
Parameters: - server_url – The Seq server URL.
- api_key – The Seq API key (optional).
- level – The minimum level at which to log.
- batch_size – The number of log entries to collect before publishing to Seq.
- auto_flush_timeout – If specified, the time (in seconds) before the current batch is automatically flushed.
- additional_handlers – Additional `LogHandler`s (if any).
- override_root_logger – Override the root logger, too? Note - this might cause problems if third-party components try to be clever when using the logging.XXX functions.
Returns: The SeqLogHandler that sends events to Seq. Can be used to forcibly flush records to Seq.
Return type:
Submodules¶
seqlog.structured_logging module¶
-
class
seqlog.structured_logging.
SeqLogHandler
(server_url, api_key=None, batch_size=10, auto_flush_timeout=None)[source]¶ Bases:
logging.Handler
Log handler that posts to Seq.
-
class
seqlog.structured_logging.
StructuredLogRecord
(name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, log_props=None, **kwargs)[source]¶ Bases:
logging.LogRecord
An extended LogRecord that with custom properties to be logged to Seq.
-
class
seqlog.structured_logging.
StructuredLogger
(name, level=0)[source]¶ Bases:
logging.Logger
Custom (dummy) logger that understands named log arguments.
-
makeRecord
(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)[source]¶ Create a LogRecord.
Parameters: - name – The name of the logger that produced the log record.
- level – The logging level (severity) associated with the logging record.
- fn – The name of the file (if known) where the log entry was created.
- lno – The line number (if known) in the file where the log entry was created.
- msg – The log message (or message template).
- args – Ordinal message format arguments (if any).
- exc_info – Exception information to be included in the log entry.
- func – The function (if known) where the log entry was created.
- extra – Extra information (if any) to add to the log record.
- sinfo – Stack trace information (if known) for the log entry.
-
-
class
seqlog.structured_logging.
StructuredRootLogger
(level=0)[source]¶ Bases:
logging.RootLogger
Custom root logger that understands named log arguments.
-
makeRecord
(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)[source]¶ Create a LogRecord.
Parameters: - name – The name of the logger that produced the log record.
- level – The logging level (severity) associated with the logging record.
- fn – The name of the file (if known) where the log entry was created.
- lno – The line number (if known) in the file where the log entry was created.
- msg – The log message (or message template).
- args – Ordinal message format arguments (if any).
- exc_info – Exception information to be included in the log entry.
- func – The function (if known) where the log entry was created.
- extra – Extra information (if any) to add to the log record.
- sinfo – Stack trace information (if known) for the log entry.
-
-
seqlog.structured_logging.
get_global_log_properties
(logger_name=None)[source]¶ Get the properties to be added to all structured log entries.
Parameters: logger_name (str) – An optional logger name to be added to the log entry. Returns: A copy of the global log properties. Return type: dict