Splunk logger sends log messages to splunk directly from your Python code.
Project description
Splunk logger
A logging handler for Splunk. Lets you send information to Splunk directly from your Python code.
Usage
import logging from splunk_logger import SplunkLogger ACCESS_TOKEN = '...' PROJECT_ID = '...' splunk_logger = SplunkLogger(ACCESS_TOKEN, PROJECT_ID) logging.getLogger('').addHandler(splunk_logger) logging.error('This is sent to splunk')
After a couple of seconds of waiting for Splunk to process the new information, you should be able to see something like this in the web interface:
{ data : "This is sent to splunk", level : "ERROR", line : 1, module : "<stdin>" }
When using the code in a real Python program, and not from the python console, the real line number and module name are used.
Enhancements
There are a couple of things which could be improved in this module
python-requests module could be used in order to use HTTP’s keep-alive and avoid creating a new TCP/IP connection for each message sent to Splunk
The logger could be refactored to send the messages in an async manner, this will make logging.foo() calls return immediately instead of waiting for the log message to be sent.
Pull requests are more than welcome!
Reporting bugs
Report your issues and feature requests in Splunk Logger’s issue tracker and I’ll be more than glad to fix them.
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
File details
Details for the file splunk_logger-0.1.1.tar.gz
.
File metadata
- Download URL: splunk_logger-0.1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97e2a7cfa323041d43688457afd003f86ca842196ad3cd52f691a7254d34f257 |
|
MD5 | e8a51146cf5851891dcb404d1933b5ae |
|
BLAKE2b-256 | f068341281aa6f78f84511884d94a5a8e68d0e935c07a216c7c47c4e29e54b92 |