Documentation ¶
Index ¶
Constants ¶
const ( LevelTrace = 0 LevelDebug = 1 LevelInfo = 2 LevelNotice = 3 LevelWarning = 4 LevelError = 5 LevelFatal = 6 LevelAudit = 7 )
const ( TextLevelTrace = "trace" TextLevelTraceEnter = "enter" TextLevelTraceExit = "exit" TextLevelDebug = "debug" TextLevelInfo = "info" TextLevelNotice = "notice" TextLevelWarning = "warning" TextLevelError = "error" TextLevelFatal = "fatal" TextLevelAudit = "audit" )
Variables ¶
var Levels = []int{ LevelTrace, LevelDebug, LevelInfo, LevelNotice, LevelWarning, LevelWarning, LevelError, LevelFatal, LevelAudit, }
var TextLevels = []string{ TextLevelTrace, TextLevelDebug, TextLevelInfo, TextLevelNotice, TextLevelWarning, TextLevelWarning, TextLevelError, TextLevelFatal, TextLevelAudit, }
Functions ¶
func ConvertFromTextLevel ¶
func DefaultHandler ¶
func DefaultHandler(log Log)
func HumanReadableHandler ¶
func HumanReadableHandler(log Log)
func IsValidLevel ¶
Types ¶
type Auth ¶
type Auth struct { Type string `json:"type"` Identifier string `json:"identifier"` Meta M `json:"meta"` }
A public struct to encapsulate the auth details for a log entry
type Commit ¶
type Commit struct { Repository string `json:"repository"` Hash string `json:"hash"` Tags []string `json:"tags"` Meta M `json:"meta"` }
A public struct to encapsulate the commit details for a log entry
type IDiary ¶
type IDiary interface { // Page returns a diary.Page interface instance for consumption // In a page scope all logs will be linked to the same page identifier // This allows us to trace the entire page chain easily for troubleshooting and profiling // // - level: The default level to log at [NOTE: If -1 will inherit from diary instance] // - sample: A per second count indicating how frequently traces should be sampled, only applicable if level is higher than DEBUG [NOTE: if value is less than zero then will sample all traces] // - catch: A flag indicating if the scope should automatically catch and return errors. [NOTE: If set to true panics will be caught and returned as an error.] // - category: The shorthand code used to identify the given workflow category [NOTE: Categories will be concatenated by dot-nation: "main.sub1.sub2.sub3".] // - authType: The shorthand code for the type of auth account (may be empty) // - authIdentifier: The identifier, which can be anything, used to identify the given auth account (may be empty) [WARNING: Don't ever log personal data without first encrypting or salt-hashing the data.] // - authMeta: Can contain any other additional data that you may require on logs for troubleshooting (may be empty) [WARNING: Don't ever log personal data without first encrypting or salt-hashing the data.] Page(level int, sample int, catch bool, category string, pageMeta M, authType, authIdentifier string, authMeta M, scope S) // Page returns a diary.Page interface instance for consumption // In a page scope all logs will be linked to the same page identifier // This allows us to trace the entire page chain easily for troubleshooting and profiling // // - level: The default level to log at [NOTE: If -1 will inherit from diary instance] // - sample: A per second count indicating how frequently traces should be sampled, only applicable if level is higher than DEBUG [NOTE: if value is less than zero then will sample all traces] // - catch: A flag indicating if the scope should automatically catch and return errors. [NOTE: If set to true panics will be caught and returned as an error.] // - category: The shorthand code used to identify the given workflow category [NOTE: Categories will be concatenated by dot-nation: "main.sub1.sub2.sub3".] // - authType: The shorthand code for the type of auth account (may be empty) // - authIdentifier: The identifier, which can be anything, used to identify the given auth account (may be empty) [WARNING: Don't ever log personal data without first encrypting or salt-hashing the data.] // - authMeta: Can contain any other additional data that you may require on logs for troubleshooting (may be empty) [WARNING: Don't ever log personal data without first encrypting or salt-hashing the data.] PageX(level int, sample int, catch bool, category string, pageMeta M, authType, authIdentifier string, authMeta M, scope S) error // Load a page using the JSON definition to chain multiple logs together when crossing micro-service boundaries Load(data []byte, category string, scope S) // Load a page using the JSON definition to chain multiple logs together when crossing micro-service boundaries LoadX(data []byte, category string, scope S) error }
An definition of the public functions for a diary instance
func Dear ¶
func Dear(client, project, service string, serviceMeta M, repository, commitHash string, commitTags []string, commitMeta M, level int, handler H) IDiary
Dear returns a diary.Diary interface instance for consumption
- client: The shorthand code used to identify which client the log belongs to - project: The shorthand code used to identify which client-project the log belongs to - service: The shorthand code used to identify which service the log belongs to - serviceMeta: Can contain any other additional data that you may require on logs for troubleshooting (may be empty) [WARNING: Don't ever log personal data without first encrypting or salt-hashing the data.]
- repository: The URI of the source-code repository (may be empty) - commitHash: The shorthand hash of the given source commit that the service was built off of (may be empty) - commitTags: The tags associated with the given source commit that the service was built off of (may be empty) - commitMeta: Can contain any other additional data that you may require on logs for troubleshooting (may be empty) [WARNING: Don't ever log personal data without first encrypting or salt-hashing the data.]
- level: The default level to log at [NOTE: Normally NOTICE for production services] - handler: A routine to handle log entries [NOTE: ]
type IPage ¶
type IPage interface { Parent() IDiary Debug(key string, value interface{}) Info(category string, meta M) Notice(category string, meta M) Warning(category, message string, meta M) Error(category, message string, meta M) Fatal(category, message string, code int, meta M) Audit(category string, meta M) ToJson() []byte Scope(category string, scope S) error }
An definition of the public functions for a page instance
type Log ¶
type Log struct { Service Service `json:"service"` Commit Commit `json:"commit"` Chain Chain `json:"chain"` Level string `json:"level"` Category string `json:"category"` Line string `json:"line"` Stack string `json:"stack"` Message string `json:"message"` Meta M `json:"meta"` Time time.Time `json:"time"` }
A public struct to encapsulate the log entry details
type Service ¶
type Service struct { Client string `json:"client"` Project string `json:"project"` Service string `json:"service"` Host string `json:"host"` HostIps []string `json:"hostIps"` ProcessId int `json:"pid"` ParentProcessId int `json:"ppid"` Meta M `json:"meta"` }
A public struct to encapsulate the service details for a log entry