Skip to main content

sharklog

Python logging helper.

PyPI License PyPI Version

Quick Start

  • Install sharklog:
python3 -m pip install sharklog
  • Use in standalone script:
# standalone.py
import sharklog

sharklog.init(debug=True)    # init current logger with level=sharklog.DEBUG

sharklog.debug("debug message")
sharklog.info("info message")
sharklog.warning("warning message")
sharklog.error("error message")

The default format of log messages is:

"[%(levelname)s]: %(message)s [%(asctime)s](%(filename)s:%(lineno)d)"

Usage

Use in standalone script

If you want to change logging level for a module, you can set it in the module by:

import sharklog
sharklog.getLogger().setLevel(logging.DEBUG)

or set it outside the module by specifying the logger name:

import sharklog
sharklog.getLogger("module_name").setLevel(logging.DEBUG)

Usage in Package Development

Now I assume your file structure is like this:

--- parent_package
    |--- __init__.py
    |--- parent_module.py
    |--- logger.py
    |--- sub_package
        |--- __init__.py
        |--- sub_module.py
  • First, you can add NullHandler to the root logger in parent_package/__init__.py, which logger named parent_package:
# parent/__init__.py
from sharklog import logging

logging.getLogger().addHandler(logging.NullHandler())

This is mentioned in the Python Logging HOWTO to identify the logger's default behavior.

  • Then, use logging in your package, they will be prefixed with the logger name parent_package.:
# parent_module.py which is placed under package `parent_package`
from sharklog import logging

logger = logging.getLogger()    # the logger name will be `parent_package.parent_module`

logger.debug("debug message")
logger.info("info message")
logger.warning("warning message")
logger.error("error message")

If you already using builtin logging module, you can use sharklog as a drop-in replacement.

Just change import logging into from sharklog import logging. Then you can use logging as usual:

# sub_module.py
from sharklog import logging

# these log messages will be prefixed with the logger name `xxxpackage.xxmodule.module_name`
# here, as an example, the logger name will be `parent_package.sub_package.sub_module`
logging.debug("debug message")
logging.info("info message")
logging.warning("warning message")
logging.error("error message")
  • Finally, you can set the logging level for the package in the main script which using the package:
# main.py
from sharklog import logging

from parent_package import parent_module
from parent_package.sub_package import sub_module

if __name__ == "__main__":
    logging.init(debug=True)    # init current logger with level=logging.DEBUG
    # or logging.init(level=logging.DEBUG)
    # logging inside the package will use the level set here

Or if you want to change the logging level for a specific module, you can set it in the module by:

from sharklog import logging
logging.getLogger().setLevel(logging.WARNING)

Metadata

Release files for sharklog 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharklog 0.1.2
File Size Uploaded Provenance Actions
sharklog-0.1.2.tar.gz 7.2 kB With provenance Details for sharklog-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sharklog 0.1.2
File Interpreter ABI Platform Actions
sharklog-0.1.2-py3-none-any.whl Python 3 none any Details for sharklog-0.1.2-py3-none-any.whl

Total release size: 14.2 kB

Release files / sharklog-0.1.2.tar.gz

Download URL sharklog-0.1.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ccf41d0a1666772564f8fbb2b4b2ba887206b9be365e5b3191b219e738b1d34e
BLAKE2b-256 checksum
How to use checksums
7037e0d09734495fbf2b4268b736d9cdd616e40fdae52a18c6a1fdfe37d490e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2025.

Transparency log

Release files / sharklog-0.1.2-py3-none-any.whl

Download URL sharklog-0.1.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db3b238a96705d9b0eb8ff7246c7d35fdd0515267895bdd3ed3dc84e87804ad8
BLAKE2b-256 checksum
How to use checksums
38bd603d4b68740847094be6e7744379a42c84023f0fc37a7cd8d5adba37c010
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2025.

Transparency log

Security for sharklog 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sharklog-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page