Skip to main content

Python integration package for LogHarvestor

Project description

LogHarvestor Logo

Log Harvestor - LinkedIn   LogHarvestor - Twitter   Log Harvestor - You Tube

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:

  1. Go to LogHarvestor.com
  2. Register for a new Account (This is free) Register
  3. Create a new Forwarder - Link
  4. 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


  1. Keep your Logging specific, and consise. This makes searching faster and more accurate
  2. No need to add timestamps or info about the forwarder. This information is automatically included with the log.

LogHarvestor Logo

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

log-harvestor-py-1.0.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

log_harvestor_py-1.0.0-py3-none-any.whl (3.7 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