Python integration package for LogHarvestor
Project description
log-harvestor-py
Documentation
See API Docs for Log-Harvestor API Documetnation.
This package is specific to Python
.
Please see our docs for other supported languages, or use standard HTTP requests.
Installation
pip install log-harvestor-py
Usage
This package requires that you have a Log Harvestor account, and Forwarder's created. If you have not done this yet:
- Go to LogHarvestor.com
- Register for a new Account (This is free) Register
- Create a new Forwarder - Link
- Generate a Forwarder Token
Now you can use this forwarder token to send logs, by adding it to the config:
from logharvestor import Forwarder
pvt_token = 'your_forwarder_token'
fwdr = Forwarder(token=token, verbose=True)
fwdr.log('test', {"title": 'Hello World'})
Configuration
Option | Default | Description |
---|---|---|
Token | "" | The JWT token assigned to your forwarder |
ApiUrl | https://app.logharvestor.com/log | This should never change unless using proxies |
Verbose | false | Verbose mode prints info to the console |
Examples
-
Configuring
from logharvestor import Forwarder
pvt_token := "your_forwarder_token"
fwdr = Forwarder(token=token, verbose=True)
-
Test Connection
from logharvestor import Forwarder
pvt_token := "your_forwarder_token"
fwdr = Forwarder(token=token, verbose=True)
success, res = fwdr.test_conn()
# `success` != True, the connection failed
# `res` contains the error that occured
# Error Examle (Invalid Token):
# False, <Response [401]>
-
Logging
from logharvestor import Forwarder
pvt_token := "your_forwarder_token"
fwdr = Forwarder(token=token, verbose=True)
# Strings
fwdr.log('test', msg="Hello World!")
# Numbers
fwdr.log('test', msg=123)
# Objects / Dicts
fwdr.log('test', msg={"a": 123, "b": "456", "c": "hello"})
# Arrays / Lists
fwdr.log('test', msg=["hello", "mars", "goodbye", "world"]))
fwdr.log('test', msg=[1, 2, 34, 567, 8, 90])
# Mixed
fwdr.log('test', msg={"a": 123, "b": {"c": "123", "d": {}}})
# Nested
fwdr.log('test', msg=[123, "abc", [1, 2, 3], {"question": "Hello?", "answer": "World!"}, {"question": "So long?", "answer": "Thanks for all the fish!"}])
Recomendations
- Keep your Logging specific, and consise. This makes searching faster and more accurate
- No need to add timestamps or info about the forwarder. This information is automatically included with the log.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
log-harvestor-py-1.0.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for log_harvestor_py-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a0dc6624a5446b8b3b4a4ea936bac0ace5f384480ddf20671b2137ef76fbfcd |
|
MD5 | e34e010d970e1b5e736984fe8b2734b7 |
|
BLAKE2b-256 | 24d35e78c6ef70be5b8721fa07ba7ac0167934607a8edb4815ab2d1a7a1a877e |