-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
123 lines (114 loc) · 4.28 KB
/
structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package logger
import (
gclogging "cloud.google.com/go/logging"
)
// Logger ...
// The base logging struct
type Logger struct {
Config *LoggingConfig
Client LoggingClient
Chain map[string][]InformationConstruct
}
// LoggingClient ...
type LoggingClient interface {
new(config *LoggingConfig) error
Log(*InformationConstruct)
close()
}
// GoogleClient ...
type GoogleClient struct {
Loggers map[string]*gclogging.Logger
Config *LoggingConfig
Client *gclogging.Client
}
// StdClient ...
type StdClient struct {
Loggers map[string]string
Config *LoggingConfig
}
// LoggingConfig ...
type LoggingConfig struct {
// Enable or disable colors
Colors bool
// The type of logging config.
// 1. stdout
// 2. .. in development
Type string
// The default tag used for your logs.
DefaultLogTag string
// The default log level
DefaultLogLevel string
// Do you want a stack trace with your log ?
WithTrace bool
// Do you want the simplified stack trace or the default one ?
SimpleTrace bool
// Enable pretty printing in the console
PrettyPrint bool
// Include file names when logging
FilesInStack bool
// Only used for Type:google
ProjectID string
// This field is only for google cloud logging, which is still in development
Logs []string
// Path to the credentials file used for google cloud logging
CredentialsPath string
}
// InformationConstruct ...
type InformationConstruct struct {
// A log level specifically for this log entry
LogLevel string `json:"Loglevel,omitempty" xml:"LogLevel"`
// A custom log tag for this specific log entry
LogTag string `json:"LogTag,omitempty" xml:"LogTag"`
// The operation represents an execution chain, the ID of
//the operation can be used to corralate log entries.
Operation Operation `json:"Operation,omitempty" xml:"Operation"`
// Key/value labels
Labels map[string]string `json:"Labels,omitempty" xml:"Labels"`
// A custom error message
Message string `json:"Message,omitempty" xml:"Message"`
// Internal error code
Code string `json:"Code,omitempty" xml:"Code"`
// HTTP error code
HTTPCode int `json:"HTTPCode,omitempty" xml:"HTTPCode"`
// HTTP message
HTTPMessage string `json:"HTTPMessage,omitempty" xml:"HTTPMessage"`
// A custom timestamp
Timestamp int64 `json:"Timestamp,omitempty" xml:"Timestamp"`
// Indicates if the error is temporary. If a method fails with a temporary error
// it can most of the time be retired within a certain time frame.
Temporary bool `json:"Temporary,omitempty" xml:"Temporary"`
// How many times you have retried the cause function of this error
Retries int `json:"Retries,omitempty" xml:"Retries"`
// The interval of which to retry the method that caused this error.
// Seconds, Milliseconds, Microseconds, Nanoseconds.. dealers choice.
RetryInterval int `json:"RetryInterval,omitempty" xml:"RetryInterval"`
// How often should you retry the method that caused this error.
MaxRetries int `json:"MaxRetries,omitempty" xml:"MaxRetries"`
// Should this error be returned to the end-user
ReturnToClient bool `json:"-" xml:"-"`
// The original error that caused the problem.
OriginalError error `json:"-" xml:"-"`
// A hint for developers on how to potentially fix this problem
Hint string `json:"Hint,omitempty" xml:"Hint"`
// The current stack trace in slice format
StackTrace string `json:"-" xml:"-"`
// The current stack trace in string format
SliceStack []string `json:"StackTrace,omitempty" xml:"StackTrace"`
// If a database query or any kind of search parameters were in play they can be placed here.
Query string `json:"Query,omitempty" xml:"Query"`
// The timing of the before mentioned query
QueryTiming int64 `json:"QueryTiming,omitempty" xml:"QueryTiming"`
QueryTimingString string `json:"QueryTimingString,omitempty" xml:"QueryTimingString"`
// The current session
Session string `json:"Session,omitempty" xml:"Session"`
}
// Operation ...
type Operation struct {
ID string `json:"ID,omitempty" xml:"ID"`
// The method, route, file, etc.. that profuced this error
Producer string `json:"Producer,omitempty" xml:"Producer"`
// If this is the first instance of logging for this operation this should be set to true
First bool `json:"First,omitempty" xml:"First"`
// If this is the last instance of logging for this opperation this should be set to false.
Last bool `json:"Last,omitempty" xml:"Last"`
}