-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds examples, updates README and removes logger subdirectory
- Loading branch information
Showing
7 changed files
with
64 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/logdna/logger-go" | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
key := "YOUR INGESTION KEY" | ||
|
||
// Configure your options with your desired level, hostname, app, ip address, mac address and environment. | ||
// Hostname is the only required field in your options- the rest are optional. | ||
options := Options{} | ||
options.Level = "fatal" | ||
options.Hostname = "gotest" | ||
options.App = "myapp" | ||
options.IPAddress = "10.0.1.101" | ||
options.MacAddress = "C0:FF:EE:C0:FF:EE" | ||
options.Env = "production" | ||
options.Tags = "logging,golang" | ||
|
||
myLogger, err := CreateLogger(options, key) | ||
fmt.Println(err) | ||
myLogger.Log("Message 1") | ||
myLogger.Close() | ||
|
||
// Can also use Go's short-hand syntax for initializing structs to define all your options in just a single line: | ||
options = Options{Level: "error", Hostname: "gotest", App: "myapp", IPAddress: "10.0.1.101", MacAddress: "C0:FF:EE:C0:FF:EE"} | ||
myLogger2, err := CreateLogger(options, key) | ||
myLogger2.Log("Message 2") | ||
|
||
// Configure options with specific logs | ||
newOptions := Options{Level: "warning", Hostname: "gotest", App: "myotherapp", IPAddress: "10.0.1.101", MacAddress: "C0:FF:EE:C0:FF:EE"} | ||
errWithOpts := myLogger2.LogWithOptions("Message 3", newOptions) | ||
fmt.Println(errWithOpts) | ||
|
||
// We support the following 6 levels | ||
myLogger2.Info("Message 1") | ||
myLogger2.Warn("Message 2") | ||
myLogger2.Debug("Message 3") | ||
myLogger2.Error("Message 4") | ||
myLogger2.Fatal("Message 5") | ||
myLogger2.Critical("Message 6") | ||
|
||
// To add metadata to every log-line created by the logger instance: | ||
options.Meta = `{"key": "value", "key2": "value2"}` | ||
myLogger3, err := CreateLogger(options, key) | ||
myLogger3.Log("Message 7") | ||
myLogger3.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package logger | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
package logger | ||
|
||
package main | ||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package logger | ||
package main | ||
|
||
import ( | ||
"errors" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package logger | ||
package main | ||
|
||
import ( | ||
"strings" | ||
|