structlog_sentry_logger._config

Module Contents

Classes

Config

Functions

add_line_number_and_func_name(logger,Β method,Β event_dict)

add_severity_field_from_level_if_in_cloud_environment(...)

A custom processor for structlog for Cloud Logging compatibility.

get_caller_name_from_frames()

get_config_dict()

Convenience function to get the local logging configuration dictionary,.

get_dev_local_filename_handler(module_name)

Builds logfile handler configs.

get_formatters()

get_git_root()

get_handlers(module_name)

get_logger([name])

Convenience function that returns a logger.

get_logging_config(module_name)

get_namespaced_module_name(__file__)

get_root_dir()

is_caller_main(caller_name)

mkdir_logs_dir(log_data_dir)

serializer(*args[,Β default,Β option])

serializer_bytes(*args[,Β default,Β option])

set_logging_config(module_name)

set_optimized_structlog_config()

set_stdlib_based_structlog_config()

Attributes

ROOT_DIR

SentryBreadcrumbJsonProcessor

getLogger

CamelCase alias for structlog_sentry_logger.get_logger.

git

class structlog_sentry_logger._config.Config[source]
stdlib_logging_config_already_configured = False
use_orjson = True
structlog_sentry_logger._config.add_line_number_and_func_name(logger, method, event_dict)[source]
Parameters
  • logger (Any) –

  • method (str) –

  • event_dict (structlog.types.EventDict) –

Return type

structlog.types.EventDict

structlog_sentry_logger._config.add_severity_field_from_level_if_in_cloud_environment(logger, method, event_dict)[source]

A custom processor for structlog for Cloud Logging compatibility.

Since Cloud Logging infers log levels from the severity key, simply duplicates level to the severity field in the logger’s event dictionary.

Parameters
  • logger (Any) –

  • method (str) –

  • event_dict (structlog.types.EventDict) –

Return type

structlog.types.EventDict

structlog_sentry_logger._config.get_caller_name_from_frames()[source]
Return type

str

structlog_sentry_logger._config.get_config_dict()[source]

Convenience function to get the local logging configuration dictionary,.

e.g., to help configure loggers from other libraries.

Returns: The logging configuration dictionary that would be used to configure the Python logging library component of the logger

Return type

dict

structlog_sentry_logger._config.get_dev_local_filename_handler(module_name)[source]

Builds logfile handler configs.

Before building the logfile handler configurations, this function attempts to initialize the log directory in the (inferred) application root directory. If this fails (for example, if the directory is read-only), it will fall back to a platform-specific temp directory. If this too fails, it will exit without creating the logfile handler configuration.

Args:

module_name: the name of the calling module which will be incorporated in the logfile file name to provide better log provenance.

Returns: logfile handler configurations if log directories are writeable, else None

Parameters

module_name (str) –

Return type

dict | None

structlog_sentry_logger._config.get_formatters()[source]
Return type

dict

structlog_sentry_logger._config.get_git_root()[source]
Return type

pathlib.Path

structlog_sentry_logger._config.get_handlers(module_name)[source]
Parameters

module_name (str) –

Return type

dict

structlog_sentry_logger._config.get_logger(name=None)[source]

Convenience function that returns a logger.

Returns: A proxy that creates a correctly configured logger bound to the __name__ of the calling module

Parameters

name (str | None) –

Return type

Any

structlog_sentry_logger._config.get_logging_config(module_name)[source]
Parameters

module_name (str) –

Return type

dict

structlog_sentry_logger._config.get_namespaced_module_name(__file__)[source]
Parameters

__file__ (pathlib.Path | str) –

Return type

str

structlog_sentry_logger._config.get_root_dir()[source]
Return type

pathlib.Path

structlog_sentry_logger._config.is_caller_main(caller_name)[source]
Parameters

caller_name (str) –

Return type

bool

structlog_sentry_logger._config.mkdir_logs_dir(log_data_dir)[source]
Parameters

log_data_dir (pathlib.Path) –

Return type

bool

structlog_sentry_logger._config.serializer(*args, default=None, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SORT_KEYS)[source]
Parameters
  • args (Any) –

  • default (Callable[[Any], Any] | None) –

  • option (int | None) –

Return type

str

structlog_sentry_logger._config.serializer_bytes(*args, default=None, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SORT_KEYS)[source]
Parameters
  • args (Any) –

  • default (Callable[[Any], Any] | None) –

  • option (int | None) –

Return type

bytes

structlog_sentry_logger._config.set_logging_config(module_name)[source]
Parameters

module_name (str) –

Return type

None

structlog_sentry_logger._config.set_optimized_structlog_config()[source]
Return type

None

structlog_sentry_logger._config.set_stdlib_based_structlog_config()[source]
Return type

None

structlog_sentry_logger._config.ROOT_DIR
structlog_sentry_logger._config.SentryBreadcrumbJsonProcessor
structlog_sentry_logger._config.getLogger

CamelCase alias for structlog_sentry_logger.get_logger.

structlog_sentry_logger._config.git