Skip to main content

Base library of python 3.6+ and asyncio, include log, config, event, metric etc.

Project description


Basic library for python 3.6+, includes:

  • config loader
  • structure logger
  • program metrics (statsd)
  • exception logger (via sentry)
  • datastructures for asyncio


Very simple and powerful log system, support structure log. It's not depends on python builtin logging module.

import asyncio
from basepy.log import logger


async def main():
    await"stuct", a=1, b=2, hello='world')

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 module is easy and powerful settings configuration with following features.

  1. keep secrets related in sperate file .secrets.toml
  2. keep local config in sperate file settings.local.toml or .secrets.local.toml, the local settings will override the settings for the same key.

So, config files should looks like

├── .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

    handlers = ["stdout", "local_fluent"]

    handler_type = "stdout"
    level = "debug"

    handler_type = "fluent"
    host = ""
    port = 24224
    tag = "basepy"
    level = "info"

To access normal setting, just use settings.key

from basepy.config import setting


Not documented, please refer the code.

Project details

Download files

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

Files for basepy, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size basepy-0.2.0-py3-none-any.whl (15.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size basepy-0.2.0.tar.gz (13.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page