-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
148 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package logadapter | ||
|
||
// custom logtype | ||
const ( | ||
LogTypeAPI = "api" | ||
LogTypeRequest = "request" | ||
LogTypeResponse = "response" | ||
LogTypeError = "error" | ||
LogTypeDebug = "debug" | ||
LogTypeInfo = "info" | ||
LogTypeWarn = "warn" | ||
LogTypeSQL = "sql" | ||
LogTypeTrace = "trace" | ||
) | ||
|
||
// custom constants | ||
const ( | ||
DefaultTimestampFormat = "2006-01-02 15:04:05.00000" | ||
DefaultPrefix = "LogAdapter_" | ||
DefaultSourceField = "stack_trace" | ||
) | ||
|
||
// Export HeaderKey constanst | ||
const ( | ||
CorrelationIDHeaderKey HeaderKey = "X-User-Correlation-Id" | ||
RequestIDHeaderKey HeaderKey = "X-Request-ID" | ||
UserInfoHeaderKey HeaderKey = "X-Userinfo" | ||
) | ||
|
||
// Export LogKey constanst | ||
const ( | ||
CorrelationIDLogKey LogKey = "correlation_id" | ||
RequestIDLogKey LogKey = "request_id" | ||
UserInfoLogKey LogKey = "user_info" | ||
) | ||
|
||
// Export default LogKeyMap | ||
var ( | ||
DefaultLogKeys []LogKey = []LogKey{CorrelationIDLogKey, RequestIDLogKey, UserInfoLogKey} | ||
baseSourceDir string | ||
) | ||
|
||
// custom log format | ||
const ( | ||
JSONFormat LogFormat = iota | ||
PrettyJSONFormat | ||
TextFormat | ||
) | ||
|
||
const ( | ||
// PanicLevel level, highest level of severity. Logs and then calls panic with the | ||
// message passed to Debug, Info, ... | ||
PanicLevel Level = iota | ||
// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the | ||
// logging level is set to Panic. | ||
FatalLevel | ||
// ErrorLevel level. Logs. Used for errors that should definitely be noted. | ||
// Commonly used for hooks to send errors to an error tracking service. | ||
ErrorLevel | ||
// WarnLevel level. Non-critical entries that deserve eyes. | ||
WarnLevel | ||
// InfoLevel level. General operational entries about what's going on inside the | ||
// application. | ||
InfoLevel | ||
// DebugLevel level. Usually only enabled when debugging. Very verbose logging. | ||
DebugLevel | ||
// TraceLevel level. Designates finer-grained informational events than the Debug. | ||
TraceLevel | ||
) |
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
Oops, something went wrong.