Skip to content

logharvestor/log-harvestor-go

Repository files navigation

LogHarvestor Logo

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

log-harvestor-go

Documentation

See API Docs for Log-Harvestor.

This package is specific to golang. Please see our docs for other supported languages, or use standard HTTP requests.

Installation


go get github.com/logharvestor/log-harvestor-go

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:

  pvt_token := "your_forwarder_token"
  fwdr := *NewForwarder(Config{Token: pvt_token})
	success, msg := suite.forwarder.log(Log{Typ: "test", Msg: bson.M{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

Note: The LogHarvestorGo v.1.x.x mod versions do not support batching or compression


Examples

  • Configuring

  pvt_token := "your_forwarder_token"
  fwdr := *NewForwarder(Config{Token: pvt_token, Verbose: true})
  • Sending Logs

  //  After config/init
  fwdr.log(Log{Typ: "whatever", Msg: bson.M{title: "Hello World"}}})
  fwdr.log(Log{Typ: "you", Msg: "GoodbyWorld"})

  type CustomLogMessageStruct struct{
    TreeName      string
    Family        string
    Age           int
    HeightFeet    int
  }
  customMsg := CustomLogMessageStruct{
    TreeType: "white pine",
    Family:   "inaceae",
    Age: 16,
    HeightFeet: 56
  }

  fwdr.log(Log{Typ: "want", Msg: bson.M{customMsg}})

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