A package for logging and timeboxing python projects
Project description
tallytime
A timeboxing and logging package for python. tallytime plugs into your existing logger to give you insight into your application's performance.
Installation
- Run
python3 -m pip install tallytime
Usage
A root TallyLog object is available out of the box:
from tallytime import display_and_delete, register, update
session_id = register("A simple user session")
// ...
update(session_id, "Finished querying database")
// ...
display_and_delete(session_id)
Custom TallyLog Objects
Additional TallyLog objects can be instantiated, each with different settings.
from tallytime.tally_log import TallyLog
from tallytime.settings import TallyLogSettings
from tallytime.loggers import DefaultFileLogger
settings = TallyLogSettings()
logger = DefaultFileLogger("./data/logs/tallytime.log")
tally_log = TallyLog(settings, logger)
session_id = tally_log.register("A simple user session")
// ...
tally_log.update(session_id, "Finished querying database")
// ...
tally_log.display_and_delete(session_id)
See Model below for more details.
Keying on Names
If you don't want to keep track of a tallytime-created session id, you can always pass in a unique string into the register invocation. Subsequent calls to tallytime methods should use the _by_name suffix, such as update_by_name or display_and_delete_by_name.
Demo
Run python3 demo.py from the repository root to see an example.
Model
tallytime involves 2 key data structures. A TallyLog is the primary interface, providing means of creating TallySessions, updating them with events, and displaying and deleting them. A TallySession is representative of an individual invocation (such as a user API request or a runtime of your program), which can be updated to track different events. All TallySessions are tracked by unique ids.
Currently, tallytime's logging capacity is built on top of python's standard logging library. TallyLog takes a logger in its constructor, which is used for information output. If you desire more extendable ways to customize the output, please reach out or add to GitHub Issues.
To work with these directly and use more configuration, import from any of the following branches:
tallytime.tally_log: The core TallyLog loggertallytime.tally_session: An individual TallyLog sessiontallytime.settings: Configuration and defaults for a TallyLog objecttallytime.exceptions: Error handling and exceptionstallytime.loggers: OOTB loggers for convenience, including DefaultConsoleLogger and DefaultFileLogger
Configuration
By default, the following settings are in place:
- All TallySessions will expire 1 hour after they are first registered if not deleted
- Log level INFO is used
- Times are rendered in seconds
- A TallySession will log its status on each update call, AND when
displayordisplay_and_deleteis called. - A TallyLog will log on its instantiation
Coming Soon
- Support more configurable logger implementations
- Support more default overrides (such as setting a higher log level for a particular session)
- Better default settings
- More timezone customization
- Testing
Credits
Implementation details inspired by the python logging library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tallytime-0.1.0.tar.gz.
File metadata
- Download URL: tallytime-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf566bbba8d43516869626c62c9ba817af3315fbd55850e44c2a641405c6b07b
|
|
| MD5 |
684a06a3d45095e369d9fbe472b0eca9
|
|
| BLAKE2b-256 |
d13194b48008b98eab06c4591f5c3f78d64173c2efd5391f6df6c39bc7907345
|
File details
Details for the file tallytime-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tallytime-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f68a75c21bf1e40c1b5c6d4dac2d54111c84ef31a6e478a6752e209c46066326
|
|
| MD5 |
e28dcb7216f84fce2089a57aef1a7e9e
|
|
| BLAKE2b-256 |
e6407d930cfd14c8e687391683970259bf6b43859b815934930d8fb72a3e3602
|