Python Logging Handler Threaded Transport
Transport for Python logging handler
Uses a background worker to log to Stackdriver Logging asynchronously.
class google.cloud.logging.handlers.transports.background_thread.BackgroundThreadTransport(client, name, grace_period=5.0, batch_size=10, max_latency=0)
Bases: google.cloud.logging.handlers.transports.base.Transport
Asynchronous transport that uses a background thread.
Parameters
client (
Client
) – The Logging client.name (str) – the name of the logger.
grace_period (float) – The amount of time to wait for pending logs to be submitted when the process is shutting down.
batch_size (int) – The maximum number of items to send at a time in the background thread.
max_latency (float) – The amount of time to wait for new logs before sending a new batch. It is strongly recommended to keep this smaller than the grace_period. This means this is effectively the longest amount of time the background thread will hold onto log entries before sending them to the server.
flush()
Submit any pending log records.
send(record, message, resource=None, labels=None, trace=None, span_id=None)
Overrides Transport.send().
Parameters
record (
logging.LogRecord
) – Python log record that the handler was called with.message (str) – The message from the
LogRecord
after being formatted by the associated log formatters.resource (
Resource
) – (Optional) Monitored resource of the entry.labels (dict) – (Optional) Mapping of labels for the entry.
trace (str) – (optional) traceid to apply to the logging entry.
span_id (str) – (optional) span_id within the trace for the log entry. Specify the trace parameter if span_id is set.