Skip to content

sfujiwara/gjhandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9d10b7c · Sep 1, 2016

History

5 Commits
Sep 1, 2016
Aug 31, 2016
Aug 31, 2016
Sep 1, 2016
Sep 1, 2016

Repository files navigation

gjhandler

gjhandler is a simple log handler which generates new line delimited JSON for Cloud Logging and google-fluentd.

Installation

pip install git+https://github.com/sfujiwara/gjhandler.git

Example

import logging
import gjhandler

logger = logging.getLogger("gj_logger")
logger.setLevel(logging.DEBUG)
logger.addHandler(gjhandler.GoogleJsonHandler(filename="log_test.json"))

logger.info("this is info")
logger.error("this is error")

Resulting Outputs

{"timestamp": {"seconds": 1472657255, "nanos": 154423952}, "message": "this is info", "severity": "INFO", "thread": 140735257141248}
{"timestamp": {"seconds": 1472657255, "nanos": 155013084}, "message": "this is error", "severity": "ERROR", "thread": 140735257141248}

Setting for google-fluentd

<source>
  type tail
  format json
  path /var/log/python/*.log,/var/log/python/*.json
  read_from_head true
  tag python
</source>

About

Python log handler for Cloud Logging

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages