Skip to main content

a1_loggermanager

Python logging.Logger manager

In this README :point_down:

Features

  • get default logger
  • add and store for use formatters, handlers, and loggers
  • set logger level
  • access logging.logger
  • easy to follow example script (see github repo)

Usage

Get a logger

import a1_loggermanager
logger_manager = a1_loggermanager.get_logger_manager()
logger = logger_manager.get_my_logger('default_console_logger')
logger.info('Created `logger_manager` and `logger`')

2024-11-15 14:50:18 INFO my_logger.py: Created logger_manager and logger

add new logger

my_logger_parms = ({
...   'name': 'logger2',
...     'handler_names': ('default_streamhandler',)
...     })
logger_manager.add_my_logger(my_logger_parms)
MyLogger(name='logger2', handlers={}, logger=<Logger logger2 (WARNING)>)
logger2 = logger_manager.get_my_logger('logger2')
logger2.info('Created `logger2`?')
logger2.set_level('info')
logger2.info('Created `logger2`!')

2024-11-15 15:10:27 INFO my_logger.py: Created logger2!

add a file handler logger and a combined console and file handler logger

set and add a file handler configuration

myh = (
  { 'name': 'default_filehandler',
    'formatter_name': 'default_format',
    'handler_type': 'FileHandler',
    'parms': {
      'filepath': filepath,
      'encoding': "utf-8",
      'mode': "a"
    }
  },
)
logger_manager.add_my_handlers(myh)

set and add a couple of logger configurations with the file handler config

myl = (
  { 'name': 'file_logger',
    'level': 'info',
    'handler_names': ('default_filehandler',),
  },
  { 'name': 'console_and_file_logger',
    'level': 'info',
    'handler_names': ('default_streamhandler', 'default_filehandler'),
  }
)
logger_manager.add_my_loggers(myl)

get the file handler logger and log an entry

file_logger = logger_manager.get_my_logger('file_logger')
file_logger.info('Created `file_logger`')

get the combined console and file handler logger and log an entry

console_file_logger = logger_manager.get_my_logger('console_and_file_logger')
console_file_logger.info('Created `console_file_logger`')

accessing logging.logger, eg;

logger2.logger.addFilter(filter_debug) 

FAQ

Is this package developed primarily for creator use?

Yes, it's a first package published to https://pypi.org/ and as much a learning tool as anything. That said the logger manager should be useful as a starting point for any similar project or just to avoid getting caught up in logging.Logger docs. Use it to easily create and manage loggers.

Contributing

If you find a bug :bug:, have a suggestion :rocket:, etc., please let me know (mike@a1publishing.com:)

Metadata

Release files for a1_loggermanager 0.1.4

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

Source distribution (sdist)

Source distribution for a1_loggermanager 0.1.4
File Size Uploaded Provenance
a1_loggermanager-0.1.4.tar.gz 8.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 15.9 kB

Release files / a1_loggermanager-0.1.4.tar.gz

Download URL a1_loggermanager-0.1.4.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
46cb56f2a7f2fed515c62f66cc6486c5ca9a39ecbce91d909d0c3fbef45a791e
BLAKE2b-256 checksum
How to use checksums
f19de90d01817c72fed9f2cbaae3520702a5dc62f0ae3cc3eadf7bd75acae890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.13.0 Windows/11

Release files / a1_loggermanager-0.1.4-py3-none-any.whl

Download URL a1_loggermanager-0.1.4-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f479f6b452e35764ceae12aaf8ec931f93d9d43108a18141396b217013768dc
BLAKE2b-256 checksum
How to use checksums
dfc1054bf9f7a1819a5ae7923b10f92bef88acb705e374bf1b5826d1138b85ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.13.0 Windows/11

Security for a1_loggermanager 0.1.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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