Skip to main content

Simple fluentd logger library

Project description

Description

Fluentd logging library used to support standardized testing.

Programmatic example (Object logging)

from fluent import sender
from fluentd_logger.logger import Logger

tag = "agent"
app_label = "api"

logger = sender.FluentSender(tag=tag, host="localhost", port=24224)
service = Logger(logger)

messages = [
  {
    "A": "A1",
    "B": "B1"
  },
  {
    "C": "C1",
    "D": "D1"
  }
]

for message in messages:
  service.emit(app_label=app_label, msg=message)

Package call pypi (File logging)

python -m fluentd_logger --file results.json --tag agent --label api --fluentd localhost:24224

Set --fluentd, --tag, --label options

There are 3 ways to set the above options

  • Add an 'environment.properties' file containing the values. E.g.
    FLUENTD_IP_PORT=localhost:24224
    TAG=Agent
    LABEL=api
    
  • Set the options through env vars. E.g.
    export FLUENTD_IP_PORT=localhost:24224, 
    export TAG=Agent
    export LABEL=4.2.1
    
  • Set the values using this CLI interactively

Supported formats

Dict - one single test result (example)

{
  "testName": "exampleTest",
  "Db": "Mysql57",
  "OS": "Centos7",
  "logLocation": "http://logdatabase.com/exampleTest",
  "startedat": "Sun Nov  1 10:16:52 EET 2020",
  "endedat": "Sun Nov  1 10:22:52 EET 2020"
}

List of Dict(s) - multiple test result (example)

[
  {
    "testName": "exampleTest1",
    "Db": "Mysql57",
    "OS": "Centos7",
    "logLocation": "http://logdatabase.com/exampleTest1",
    "startedat": "Sun Nov  1 10:16:52 EET 2020",
    "endedat": "Sun Nov  1 10:22:52 EET 2020"
  },
  {
    "testName": "exampleTest2",
    "Db": "Mysql57",
    "OS": "Centos7",
    "logLocation": "http://logdatabase.com/exampleTest2",
    "startedat": "Sun Nov  1 10:22:52 EET 2020",
    "endedat": "Sun Nov  1 10:30:52 EET 2020"
  }
]

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

fluentd_logger-1.0.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

fluentd_logger-1.0.0-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

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