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.
go get github.com/logharvestor/log-harvestor-go
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:
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"}}})
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 |
pvt_token := "your_forwarder_token"
fwdr := *NewForwarder(Config{Token: pvt_token, Verbose: true})
// 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}})
- 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.