Documentation ¶
Overview ¶
Package service holds the methods necessary to support implementation of loggers that write to alt4.
Index ¶
Constants ¶
const ModeDebug = "debug"
const ModeRelease = "release"
const ModeSilent = "silent"
const ModeTesting = "testing"
Variables ¶
var SyncWriter = alt4SyncWriter{}
SyncWriter can be used to override a normal/default go logger to write it's output to alt4 This method writes logs synchronously. Unless you really need to we instead advice on Opening and Closing a group at the end of your routines which will wait for all writes started within the routine to complete Example log.SetOutput(SyncWriter)
var Writer = alt4Writer{}
Writer can be used to override a normal/default go logger to write it's output to alt4 This method writes logs asynchronously. Opening and Closing a group at the end of your routines ensure waits for all writes to finish. Example log.SetOutput(Writer)
Functions ¶
func CloseGroup ¶
func CloseGroup()
func SetAuthToken ¶
func SetAuthToken(token string)
SetAuthToken Used to set the auth token for writing to alt4. This setting can be done via config file ALT4_CONFIG or setting environment variable ALT4_AUTH_TOKEN
func SetDebugOutput ¶
SetDebugOutput Is used to specify where alt4 emits additional output e.g. when facing network errors. Defaults os.Stderr
func SetMode ¶
func SetMode(mode string)
SetMode Sets the behaviour of alt4 based on the following: `release` - Under this mode logs are written to alt4 and not emitted to stdout `debug` - Under this mode logs are written to alt4 and emitted to stdout `testing` - Under this mode logs are not written to alt4, just emitted to stdout `silent` - Under this mode logs are not written to alt4 or emitted to stdout `json`(coming soon) - Under this mode all logs are written to a JSON file which you can later upload to alt4 Mode can also be set via a config file ALT4_CONFIG or setting environment variable ALT4_MODE Default mode is `release`
Types ¶
type DefaultHelper ¶ added in v1.0.2
type DefaultHelper struct{}
func (DefaultHelper) QueryAudit ¶ added in v1.0.2
func (helper DefaultHelper) QueryAudit(query proto.Query) (result *proto.QueryResult, err error)
func (DefaultHelper) WriteAudit ¶ added in v1.0.2
func (helper DefaultHelper) WriteAudit(msg *proto.AuditLog, result *LogResult)
type LogResult ¶
LogResult Object returned when you create a log entry.
func Log ¶
func Log(calldepth int, asGroup bool, message string, claims []*proto.Claim, level proto.Log_Level, logTime time.Time) *LogResult
Log Creates a log entry and writes it to alt4 in the background. This function should not be called directly and should instead be used from helper functions under the `log` package.
type RemoteHelper ¶ added in v1.0.2
type RemoteHelper interface { // WriteLog function will be called with the Message to be sent to alt4 and an empty LogResult to fill once done WriteLog(msg *proto.Log, result *LogResult) // WriteAudit function will be called with an audit message to be sent to alt4 and an empty LogResult to fill once done. WriteAudit(msg *proto.AuditLog, result *LogResult) // QueryAudit function will be called when you query audit logs. This function is synchronous. QueryAudit(query proto.Query) (result *proto.QueryResult, err error) }
RemoteWriter an interface for functions called when writing to alt4. You can implement this function to mock writes to alt4 for better testing of your system.
var Alt4RemoteHelper RemoteHelper = DefaultHelper{}
Alt4RemoteWriter For testing purposes, implement your own RemoteHelper and equate it to this variable