https://github.com/treasure-data/td-logger-python
Python logging module for td-agent
https://github.com/treasure-data/td-logger-python
Last synced: about 1 year ago
JSON representation
Python logging module for td-agent
- Host: GitHub
- URL: https://github.com/treasure-data/td-logger-python
- Owner: treasure-data
- Created: 2011-09-18T13:35:11.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2023-07-31T17:13:32.000Z (almost 3 years ago)
- Last Synced: 2025-03-25T16:50:54.904Z (about 1 year ago)
- Language: Python
- Homepage: http://treasure-data.com/
- Size: 27.3 KB
- Stars: 4
- Watchers: 80
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
td-logger: logging library for Treasure Data Cloud
=================================================
Setup
-----
Before using this logging handler, td-agent must be properly configured at the
localhost. Please confirm these settings are in your
/etc/td-agent/td-agent.conf.
## built-in TCP input
type tcp
# Treasure Data output
# match events whose tag is td.DATABASE.TABLE
type tdlog
apikey YOUR_API_KEY
For more information, please look at the documentation.
* http://docs.treasure-data.com/
Install
-------
$ easy_install td-logger
or
$ pip install td-logger
Usage
-----
Check out the tests folder for more samples.
import logging
from tdlog import logger
logging.basicConfig(level=logging.INFO)
l = logging.getLogger('td_logger.test')
l.addHandler(logger.TreasureDataHandler())
l.info('Some message')
js = { "semicolon" : ";", "at" : "@" }
l.info(js)
This will throw the log entries to the local td-agent. And there's an important
point. This logger accepts only 'dict' and 'json string'.
Also, these parameters are logged by default.
* sys_host
* sys_name
* sys_module
* sys_lineno
* sys_levelno
* sys_levelname
* sys_filename
* sys_funcname
* sys_exc_info
* msg
These parameters can be specified at TreasureDataHander constructor.
* host: td-agent host (default: 127.0.0.1)
* port: td-agent port (default: 24224)
* db: td database name (default: log)
* table: td table name (default: default)
* bufmax: buffer size max when td-agent is unavailable (default: 1*1024*1024)
* timeout: network timeout (default: 3.0)
Have fun!
How to Develop
--------------
Folloings are the way to setup development envionment on MacOSX.
$ sudo easy_install virtualenv
$ virtualenv --no-site-packages .
New python executable in ./bin/python
Installing setuptools............done.
Installing pip...............done.
$ source bin/activate
$ bin/pip install msgpack-python
Runing tests
$ python setup.py test
Special Thanks
--------------
- [Joshua Kuntz](https://github.com/j3kuntz) for the original work