Skip to main content

No project description provided

Project description

Info:

utilities for distributed environment

Repository:

https://github.com/situkangsayur/python-outfit

Author:

Hendri Karisma (http://github.com/situkangsayur)

Maintainer:

Hendri Karisma (http://github.com/situkangsayur)

https://travis-ci.org/situkangsayur/python-outfit.svg?branch=master https://coveralls.io/repos/github/situkangsayur/python-outfit/badge.svg?branch=master

Python Outfit is set of dependencies across a range of python standard package for software development.

Features for 0.0.4 version:

  1. Load config using yaml.

  2. Integrated to Consul.

  3. Load config file from a path in KV Consul.

  4. Integrated to Vault.

  5. Load Secret KV from Vault.

  6. add some db status to py-healtchecker.

  7. simple Logger.

  8. Load Logger configurations from consul, yaml, json, and dictionary logging var in python file.

How to install Outfit

You can use pip for installing python-outfit.

pip install python-outfit

pypi link : link to outfit

Quick Start

Just add outfit packe then import the Class that you need. First to load configuration import Outfit class. Then call Oufit.setup(‘config_path’) call setup static method and pass the path of the configuration file to Oufit.setup()

from outfit import Outfit

if __name__ == '__main__':
    Outfit.setup('conf/configuration.yaml')

Then you can import ConsulCon for Consul Connection or VaulCon for Vault Connection, or you can use Logger to do some logging text for debug, info, error, or critical mode.

from outfit import Outfit
from outfit import ConsulCon, VaultCon
from outfit import Logger

if __name__ == '__main__':
    Outfit.setup('conf/configuration.yaml')
    con_consul = ConsulCon()

    Logger.debug('get the information such as config file from consul kv then will be returned as python dictionary')
    config_dict = con_consul.get_kv()

    con_vault = VaultCon()

    Logger.info('get the secret information in vault secret kv then will be returned as python dictionary')
    secret_dict = con_vault.get_secret_kv()

The consul and vault connection will get the configs information from yaml file, including the Logger config source.

This is the example of the .yaml file for outfit configurations:

vault:
    host: localhost
    port: 9500
    scheme: http
    token: token123jhk123
    path: sample/app
consul:
    host: localhost
    port: 9500
    scheme: http
    token: token123jhk123
    path: sample/app
logconfig:
    mode: development
    source_type: yaml_file
    source_location: ./tests/assets/logging.yaml

We can see that the logconfig will provide the log configuration information, it contains mode, source_type, and source_location:

  • mode of log it depends on the logger profile that you write in log config.

  • source_type, it can be yaml_file, json_file, consul_kv, and dictionary type from python file.

  • source_location, it will provide the location of the files or consul kv directory.

Sample for log config using source_type consul kv:

vault:
    host: localhost
    port: 9500
    scheme: http
    token: token123jhk123
    path: sample/app
consul:
    host: localhost
    port: 9500
    scheme: http
    token: token123jhk123
    path: sample/app
logconfig:
    mode: development
    source_type: consulkv
    source_location: assets/logging.yaml

And for logging yaml file or the structures :

---
version: 1
disable_existing_loggers: False
formatters:
    simple:
      format: "%(asctime)s, %(levelname)s:%(filename)s(%(lineno)d)> %(message)s"

handlers:
    debug_console:
        class: logging.StreamHandler
        level: DEBUG
        formatter: simple
        stream: ext://sys.stdout

    production_console:
        class: logging.StreamHandler
        level: INFO
        formatter: simple
        stream: ext://sys.stdout


    debug_file_handler:
        class: logging.handlers.RotatingFileHandler
        level: DEBUG
        formatter: simple
        filename: tests/logs/debug.log
        maxBytes: 10485760 # 10MB
        backupCount: 20
        encoding: utf8

    info_file_handler:
        class: logging.handlers.RotatingFileHandler
        level: INFO
        formatter: simple
        filename: tests/logs/info.log
        maxBytes: 10485760 # 10MB
        backupCount: 20
        encoding: utf8

    error_file_handler:
        class: logging.handlers.RotatingFileHandler
        level: ERROR
        formatter: simple
        filename: tests/logs/errors.log
        maxBytes: 10485760 # 10MB
        backupCount: 20
        encoding: utf8

    critical_file_handler:
        class: logging.handlers.RotatingFileHandler
        level: CRITICAL
        formatter: simple
        filename: tests/logs/critical.log
        maxBytes: 10485760 # 10MB
        backupCount: 20
        encoding: utf8

loggers:
    development:
        level: DEBUG
        handlers: [debug_console, debug_file_handler, info_file_handler, error_file_handler, critical_file_handler]
        propagate: True

    production:
        level: INFO
        handlers: [production_console, info_file_handler, error_file_handler, critical_file_handler]
        propagate: True
...

you can get more detail about log config in yaml from this link

Project details


Download files

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

Source Distribution

python-outfit-0.0.6.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_outfit-0.0.6-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file python-outfit-0.0.6.tar.gz.

File metadata

  • Download URL: python-outfit-0.0.6.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.7

File hashes

Hashes for python-outfit-0.0.6.tar.gz
Algorithm Hash digest
SHA256 6c2d93e224487db284cb84de3ec1aeda85640c0e66f9508d10bfe59123c11b4c
MD5 1afeda2276aa96aadf474416e71887e8
BLAKE2b-256 c54df918698b650723b2a91c5fb784e9d407dbd246fb848250781b254922403e

See more details on using hashes here.

File details

Details for the file python_outfit-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: python_outfit-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.7

File hashes

Hashes for python_outfit-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6b64391ab728a35c0fa9c91cb13b6a2d51eacfb5184eb14936fb3d3ffcab1dc1
MD5 819e8e4e8fe999c5999d2e07362c9ebb
BLAKE2b-256 67bd4fe438c08372731d705177f09b6c10b9c92927853623adf08d6b14b08e93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page