basepy
Basic library for python 3.6+, includes:
- config loader
- structure logger
- program metrics (statsd)
- exception logger (via sentry)
- datastructures for asyncio
log
Very simple and powerful log system, support structure log. It's not depends on python builtin logging module.
import asyncio
from basepy.asynclog import logger
logger.add("stdout")
async def main():
await logger.info("hello")
await logger.info("stuct", a=1, b=2, hello='world')
asyncio.run(main())
And the code will generated.
[2020-02-01 11:42:07 +0800] [local.72267] [INFO] [hello]
[2020-02-01 11:42:07 +0800] [local.72267] [INFO] [stuct] [a = 1] [b = 2] [hello = "world"]
config
Config module is easy and powerful settings configuration with following features.
- keep secrets related in sperate file
.secrets.toml - keep local config in sperate file
settings.local.tomlor.secrets.local.toml, the local settings will override the settings for the same key.
So, config files should looks like
application
├── .secrets.local.toml
├── .secrets.toml
├── settings.local.toml
└── settings.toml
The .secrets.toml should contains several keys, like
signing_secret = "local_a"
access_token = "local_b"
To access secrets in program, just use settings.secrets
from basepy.config import settings
print(settings.secrets.signing_secret) # will print "local_a"
The settings.toml can contains very complex setting, for example
[log]
handlers = ["stdout", "local_fluent"]
[log.stdout]
handler_type = "stdout"
level = "debug"
[log.local_fluent]
handler_type = "fluent"
host = "127.0.0.1"
port = 24224
tag = "basepy"
level = "info"
To access normal setting, just use settings.key
from basepy.config import setting
print(setting.log.handlers)
more
Please refer the docs directory.
Release files for basepy 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| basepy-0.5.tar.gz | 28.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| basepy-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.7 kB
Release files / basepy-0.5.tar.gz
| Download URL | basepy-0.5.tar.gz |
|---|---|
| Size | 28.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d997bb4e930f396009a98d06fbdd7e1b06d110a917fb356603dffbbc1f948fa8
|
|
BLAKE2b-256 checksum How to use checksums |
575339f3edb0bf66656ff0f62e910ac39fa42c85d665e6a9e22b1da843ac4fa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / basepy-0.5-py3-none-any.whl
| Download URL | basepy-0.5-py3-none-any.whl |
|---|---|
| Size | 32.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa6fc57e664c7ab78d14b5026aab38cbc1001d54605d9d3c1c6c31b7c7947b81
|
|
BLAKE2b-256 checksum How to use checksums |
51166d095b765bec3da58cceff5f5a8c720f7b3f90b4a1328ad88770a70d3182
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|