Skip to main content

Automatic trace logging for Python

Project description

robocorp-log

robocorp-log is a library which provides comprehensible logging for Python with a focus on Python automation, where detailed information on what happened and why a failure occurs is of vital importance.

Note: The format of the log is not a part of the API and should not be relied upon as it can change even between minor versions.

Why

Although Python logging is flexible it may be hard to analyze the logging afterwards and visualize it. Also, the format may end up using a big amount of disk space and it may be tedious to add logging calls to all places of interest.

How

robocorp-log improves those aspects by using a structured format which enables using less disk space while also providing a viewer (log.html) for the generated content.

Also, it provides utilities to setup logging so that logging is done automatically without having to explicitly add calls to add content to the logging (although it's still possible to do so when needed).

Usage

It's recommended that robocorp-log is used through robocorp-tasks as robocorp-tasks will configure robocorp-log in a streamlined way, where you just need to worry about marking the entry point method with a @tasks decorator and it'll automatically setup the auto-logging and provide the log result in output/log.html.

Configuring with pyproject.toml

robocorp-tasks takes care of customizing robocorp-log through pyproject.toml.
See the robocorp-tasks project for more information (robocorp-log only provides the core logging structure and different libraries may customize it in different ways).

Although the setup is done through robocorp-tasks, there are still some APIs in robocorp.log which are interesting to use such as:

  • Utility methods to add a log message as critical, warn, info, debug, exception

  • Utility method to add an html message (using the html method). Note that the html method is tested for images with base64 contents in the log.html, other structures must be manually checked as they can break the layout. Also, keep in mind that the provided html will be sanitized.

  • Supressing logging through suppress_variables, suppress_methods, suppress.

  • Hiding sensitive data (automatically based on variable or argument names with names registered in add_sensitive_variable_name and add_sensitive_variable_name_pattern) or by passing the value to be hidden to hide_from_output.

Caveats

The auto import mode is done by having a pre-import hook which will change the AST at runtime. This mostly works, but there are a couple of caveats to keep in mind:

  1. Debuggers may end up stepping into the robocorp-log code in many places even if such code isn't in the source code (you may want to configure the debugger you're using to skip calls into robocorp.log as that's usually just an implementation detail).

  2. The logging needs to be fully setup prior to importing any module that should be automatically logged.

  3. Working with coroutines (async, await and greenlet) is not supported.

Guides

API Reference

Explore our API for extensive documentation.

Changelog

A list of releases and corresponding changes can be found in the changelog.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robocorp_log-3.1.2.tar.gz (348.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robocorp_log-3.1.2-py3-none-any.whl (359.2 kB view details)

Uploaded Python 3

File details

Details for the file robocorp_log-3.1.2.tar.gz.

File metadata

  • Download URL: robocorp_log-3.1.2.tar.gz
  • Upload date:
  • Size: 348.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for robocorp_log-3.1.2.tar.gz
Algorithm Hash digest
SHA256 57df58ab49c51dbdcfa1291f46bb2d02bfd4b9a5f5c8149eac4eca2ff4a845b7
MD5 940133e9e4247e7dfd15bdbdb5993f29
BLAKE2b-256 40d218edae702ae101061b22c5a5771605c6ac57a5cae87bb86d5894d4c8afe1

See more details on using hashes here.

Provenance

The following attestation bundles were made for robocorp_log-3.1.2.tar.gz:

Publisher: log_release.yml on robocorp/robocorp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file robocorp_log-3.1.2-py3-none-any.whl.

File metadata

  • Download URL: robocorp_log-3.1.2-py3-none-any.whl
  • Upload date:
  • Size: 359.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for robocorp_log-3.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 42fca280313e4985e46d8b03f99bf32cb317a796865ed370fd3fd5d58a5d1f2c
MD5 50f06de90dfd221cdfebdeb3d4c74948
BLAKE2b-256 f28d5caabec3dec63c4f8f1e7d748a3e6310b5f71bfa328483c27f62bb52069f

See more details on using hashes here.

Provenance

The following attestation bundles were made for robocorp_log-3.1.2-py3-none-any.whl:

Publisher: log_release.yml on robocorp/robocorp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page