Skip to main content
View module source on GitHub Module for handling log writing operations in the Maxim SDK. This module provides classes for configuring and managing log writing, including automatic flushing, file-based persistence, and API integration.

LogWriterConfig

Configuration class for the LogWriter. Attributes:

__init__

Initialize a LogWriterConfig instance. Arguments:

LogWriter

Handles writing logs to the Maxim API and local filesystem. This class manages a queue of logs, periodically flushes them to the API, and provides fallback to local filesystem storage when API calls fail.

__init__

Initialize a LogWriter instance. Arguments: Raises:
  • ValueError - If auto_flush is enabled but flush_interval is None.

repository_id

Get the repository ID. Returns:

upload_file_data

Upload a file attachment to the Maxim API.

upload_file

Upload a file data attachment to the Maxim API.

upload_attachments

Upload all attachments to the Maxim API.

upload_attachment

Upload an attachment to the Maxim API. Arguments:

is_running_on_lambda

Check if the code is running in an AWS Lambda environment. Returns:

write_to_file

Write logs to a local file. Arguments: Returns: str or None: Path to the file if successful, None otherwise. Raises:
  • Exception - If raise_exceptions is True and writing fails.

flush_log_files

Flush logs from files to the Maxim API. This method reads log files from the logs directory, sends them to the API, and deletes the files if successful. Raises:
  • Exception - If raise_exceptions is True and an error occurs.

can_access_filesystem

Check if the filesystem is accessible for writing. Returns:

flush_logs

Flush logs to the Maxim API. This method attempts to send logs to the API, with fallback mechanisms for handling failures based on the environment. Arguments:

commit

Add a log to the queue for later flushing. Arguments: Raises:
  • ValueError - If the entity_id is invalid and raise_exceptions is True.

flush_upload_attachment_logs

Flush all queued attachments to the Maxim API. This method empties the queue and sends all logs to the API, with special handling for AWS Lambda environments.

flush_commit_logs

Flush all queued commit logs to the Maxim API. This method empties the queue and sends all logs to the API, with special handling for AWS Lambda environments.

flush

Flush all queued logs to the Maxim API.

cleanup

Clean up resources used by the LogWriter. This method stops the flush thread, flushes any remaining logs, and shuts down the executor.