A oneuptime sdk for application logger that can be used to send logs about your applications created on your fypie dashboard which can also used for error tracking
Via Go
// TODO how to install package
// TODO fix import properly
import (
"fmt"
)
// constructor
option := LoggerOptions{
ApiUrl: "API_URL", // https://oneuptime.com/api
ApplicationLogId: "APPLICATION_LOG_ID",
ApplicationLogKey: "APPLICATION_LOG_KEY",
}
// initalization
Init(option)
// Sending a string log to the server
item := "This is a simple log"
// empty tag
var tag = []string{}
logResponse, logErr := LogInfo(item, tag)
// response after logging a request
fmt.PrintF("Log Info response: %v", logResponse)
fmt.PrintF("Log Info error: %v", logErr)
// Sending a struct log to the server
type StructA struct {
Name string
Location string
}
item := StructA{"Tony Lewinsky","Liverpool"}
// empty tag
var tag = []string{}
logResponse, logErr := LogInfo(item, tag)
// response after logging a request
ffmt.PrintF("Log Info error: %v", logErr)
// alternatively, tags can be added to the logged item.
item := "This is a simple log"
// using a tag string
var tag = []string{"server-side-error"}
logResponse, logErr := LogWarning(item, tag)
// response after logging a request
fmt.PrintF("Log Warning response: %v", logResponse)
fmt.PrintF("Log Warning error: %v", logErr)
// Using an array of strings
var tags = []string{"server", "error"}
logResponse, logErr := LogError(item, tags)
// response after logging a request
fmt.PrintF("Log Error response: %v", logResponse)
fmt.PrintF("Log Error error: %v", logErr)
// TODO fix import properly
import (
"fmt"
)
// set up tracking configurations
timelineOpt := TrackerOption{
MaxTimeline: 2,
CaptureCodeSnippet: true,
}
option := OneUptimeTrackerOption{
ErrorTrackerId: "ERROR_TRACKER_ID",
ErrorTrackerKey: "ERROR_TRACKER_KEY",
ApiUrl: "API_URL", // https://oneuptime.com/api,
Options: timelineOpt, // optional
}
InitTracker(option)
// capturing a timeline manually
var customTimeline = &Timeline{
Category: "testing",
Data: "payment-confirmation",
Type: "info",
}
AddToTimeline(customTimeline)
// setting custom tags
// a single tag
SetTag("location","Warsaw")
// multiple tags
// create three tags
tags := map[string]string{
"location": "Warsaw",
"agent": "Safari",
"actor": "Tom Cruise",
}
// setting the array of tags
SetTags(tags)
// all error exception captured are set to your oneuptime dashboard
// this sdk can capture errors managed by go-errors or pkg/errors
err := errors.Errorf("Dang! Error Happened")
// capture error
CaptureException(err)
// alternatively, you can capture error using the message method
CaptureMessage("Dang! Error Again")
Main API to send logs to the server.
Author: HackerBay, Inc.
- OneUptime SDK
Create a constructor from the class, which will be used to send logs to the server.
Kind: Constructor
Returns: Initialized Logger
Param | Type | Description |
---|---|---|
LoggerOptions | struct |
The Object containing the Log Container details |
LoggerOption
Kind: Struct
Returns: null
Param | Type | Description |
---|---|---|
ApiUrl | string |
The Server URL. |
ApplicationLogId | string |
The Application Log ID. |
ApplicationLogKey | string |
The Application Log Key. |
Logs a request of type info
to the server.
Kind: method of OneUptimeLogger.new
Returns: Object
- An object response of a success or failure.
Param | Type | Description |
---|---|---|
log | string | Struct |
The content to the logged on the server. |
tags | string | Array |
The tag(s) to be attached to the logged item on the server. |
Logs a request of type warning
to the server.
Kind: method of OneUptimeLogger.new
Returns: Object
- An object response of a success or failure.
Param | Type | Description |
---|---|---|
warning | string | Struct |
The content to the logged on the server. |
tags | string | Array |
The tag(s) to be attached to the logged item on the server. |
Logs a request of type error
to the server.
Kind: method of OneUptimeLogger.new
Returns: Object
- An object response of a success or failure.
Param | Type | Description |
---|---|---|
error | string | Struct |
The content to the logged on the server. |
tags | string | Array |
The tag(s) to be attached to the logged item on the server. |
Create a constructor from the class, which will be used to track errors sent to the server.
Kind: Constructor
Returns: Initialized Tracker
Param | Type | Description |
---|---|---|
OneUptimeTrackerOption | struct |
The Object containing the Error Tracking Container details and tracker option |
Kind: Struct
Returns: null
Param | Type | Description |
---|---|---|
ApiUrl | string |
The Server URL. |
ErrorTrackerId | string |
The Error Tracker ID. |
ErrorTrackerKey | string |
The Error Tracker Key. |
Option | TrackerOption |
The options to be considred by the tracker. |
Param | Type | Description |
---|---|---|
MaxTimeline | int |
The total amount of timeline that should be captured, defaults to 5 |
CaptureCodeSnippet | boolean |
When set as true stack traces are automatically attached to all error sent to your oneuptime dashboard. |
Set tag for the error to be sent to the server.
Kind: method of OneUptimeTracker
Returns: null
Param | Type | Description |
---|---|---|
key | string |
The key for the tag. |
value | string |
The value for the tag. |
Set multiple tags for the error to be sent to the server. Takes in a map of string of string
Kind: method of OneUptimeTracker
Returns: null
Param | Type | Description |
---|---|---|
tags | map[string]string |
The key for the tag. |
Set fingerprint for the next error to be captured.
Kind: method of OneUptimeTracker
Returns: null
Param | Type | Description |
---|---|---|
fingerprint | list of strings |
The set of string used to group error messages on the server. |
Add a custom timeline element to the next error to be sent to the server
Kind: method of OneUptimeTracker
Returns: null
Param | Type | Description |
---|---|---|
category | string |
The category of the timeline event. |
content | string | struct |
The content of the timeline event. |
type | string |
The type of timeline event. |
Capture a custom error message to be sent to the server
Kind: method of OneUptimeTracker
Returns: response
Param | Type | Description |
---|---|---|
message | string |
The message to be sent to the server. |
Capture a custom error object to be sent to the server
Kind: method of OneUptimeTracker
Returns: response
Param | Type | Description |
---|---|---|
error | Error object |
The Error Object to be sent to the server. |
- Clone repository
- run
cd GoSDK
- run
go get -d ./...
to install dependencies - run
go test -v
to run tests