Logging

en_core.logging

We expose the full logging module interface and add some additional utility functions.

critical_check(condition, message, *args, **kwargs)

Logs critical message and data if the condition fails.

Parameters
  • condition (expression) – Conditional expression to evaluate.

  • message (str) – Message to log if the condition fails.

Params args

Additional data to log.

Params kwargs

Additional keyword arguments to log.

debug_check(condition, message, *args, **kwargs)

Logs debug message and data if the condition fails.

Parameters
  • condition (expression) – Conditional expression to evaluate.

  • message (str) – Message to log if the condition fails.

Params args

Additional data to log.

Params kwargs

Additional keyword arguments to log.

error_check(condition, message, *args, **kwargs)

Logs error message and data if the condition fails.

Parameters
  • condition (expression) – Conditional expression to evaluate.

  • message (str) – Message to log if the condition fails.

Params args

Additional data to log.

Params kwargs

Additional keyword arguments to log.

info_check(condition, message, *args, **kwargs)

Logs info message and data if the condition fails.

Parameters
  • condition (expression) – Conditional expression to evaluate.

  • message (str) – Message to log if the condition fails.

Params args

Additional data to log.

Params kwargs

Additional keyword arguments to log.

initialize_log_file(filename, format='%(asctime)s - %(levelname)s: %(message)s')

Adds a rotating file log handler to the logger useful to troubleshoot problems with applications in production. Applications should call initialize_logging() first to insure logging is properly initialized and that we log to both files and standard output.

Parameters
  • filename (str) – Base name of the file to log to.

  • format (str) – Formatting string for the new handler. If not specified, uses default which should be fine for most applications.

log_json(jobj, prefix='')

Logs a JSON object.

Parameters
  • jobj (json) – Object to log.

  • prefix (str) – Prefix to the output. If not specified, it uses the string JSON.

log_lambda_event(event)

Logs a lambda event object.

Parameters

event (event) – Event object to be logged.

log_response(response)

Logs a http response status and body.

Parameters

response (response) – The response object to log.

warning_check(condition, message, *args, **kwargs)

Logs warning message and data if the condition fails.

Parameters
  • condition (expression) – Conditional expression to evaluate.

  • message (str) – Message to log if the condition fails.

Params args

Additional data to log.

Params kwargs

Additional keyword arguments to log.