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/solomon-bush/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{Type: "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{Type: "whatever", Msg: bson.M{title: "Hello World"}}})
fwdr.log(Log{Type: "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{Type: "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.