Nameko extension exposing a structlog dependency injector
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
nameko_structlog
tests
.editorconfig
.gitignore
HISTORY.rst
LICENSE
MANIFEST.in
Makefile
README.rst
setup.cfg
setup.py
tox.ini

README.rst

nameko-structlog

Structlog as nameko extension

  • Free software: Apache Software License 2.0

Extension for nameko that replaces python logging module with structlog.

Installation

To install nameko-structlog, simply use pip.

pip install nameko-structlog
# to enable coloring during development
pip install nameko-structlog[colors]

Usage

Add Structlog log level to your nameko config file:

# config.yml
STRUCTLOG:
   DEVELOPMENT_MODE: ${DEV:false}
   WORKER_NAME: ${WORKER_NAME:false}

...

Include the StructlogDependency dependency in your service class:

# service.py
from nameko.rpc import rpc

from nameko_structlog import StructlogDependency

class MyService(object):
   name = 'demo'

   log = StructlogDependency()

   @rpc
   def my_method(self, name):
      self.log.info('Your name is '.format(name))

Run your service, providing the config file:

$ nameko run service --config config.yaml

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.