Skip to content

bulk_rotating_device_handler

messageflux.logging.bulk_rotating_device_handler

BulkRotatingDeviceHandler

BulkRotatingDeviceHandler(
    live_log_path,
    output_device_manager,
    output_device_name,
    metadata=None,
    bkp_log_path=None,
    max_records=1000,
    max_time=60,
    live_log_prefix="",
    wait_on_queue_timeout=1.0,
)

Bases: BulkRotatingHandlerBase

Handler for logging into an output device when the current file reaches a certain size or time.

Open a log file and use it as the stream for logging. when max_records are written, or max_time has passed, a rollover occurs rollover copies the live log from live_log_path to rotated_log_path

Parameters:

Name Type Description Default
live_log_path str

the path to write the live log to

required
output_device_manager OutputDeviceManager

the device manager to send the logs to

required
output_device_name str

the name of the output_device to send to

required
metadata Optional[Dict[str, Any]]

a dictionary of metadata to send on the device along with the log

None
bkp_log_path Optional[str]

the path to write to rotated log to, if writing to rotated_log_path fails

None
max_records int

the maximum number of records to write before rotation

1000
max_time int

the maximum time (in seconds) to wait before rotation

60
live_log_prefix str

the prefix for live log file

''
wait_on_queue_timeout float

the timeout in seconds to wait for the publish queue to have messages. must be greater then 0. lower number will make the thread busy wait. higher number will take more time to kill thread when close is called

1.0

close

close()

closes the handler (disconnects from the output device)