package
1.54.0
Repository: https://github.com/lacework/go-sdk.git
Documentation: pkg.go.dev

# README

Lacework Logger

A wrapper Logger Go package for Lacework projects based of zap.

Usage

Download the library into your $GOPATH:

$ go get github.com/lacework/go-sdk/lwlogger

Import the library into your tool:

import "github.com/lacework/go-sdk/lwlogger"

Environment Variables

This package can be controlled via environment variables:

Environment VariableDescriptionDefaultSupported Options
LW_LOGChange the verbosity of the logs""INFO or DEBUG
LW_LOG_FORMATControls the format of the logsJSONJSON or CONSOLE
LW_LOG_DEVSwitch the logger instance to development mode (extra verbose)falsetrue or false

Examples

To create a new logger instance with the log level INFO, write an interesting info message and another debug message. Note that only the info message will be displayed:

package main

import "github.com/lacework/go-sdk/lwlogger"

func main() {
	lwL := lwlogger.New("INFO")

	lwL.Debug("this is a debug message, too long and only needed when debugging this app")
	// This message wont be displayed

	lwL.Info("interesting info")
	// Output: {"level":"info","ts":"[timestamp]","caller":"main.go:9","msg":"interesting info"}
}

Look at the examples/ folder for more examples.

# Functions

LogLevelFromEnvironment checks the environment variable 'LW_LOG'.
Merges multiple loggers into one.
New initialize a new logger with the provided level and options.
No description provided by the author
NewWithWriter initialize a new logger with the provided level and options but redirecting the logs to the provider io.Writer.
No description provided by the author

# Variables

No description provided by the author
LogDevelopmentModeEnv switches the logger to development mode.
LogFormatEnv controls the format of the logger.
LogLevelEnv represents the level that the logger is configured.
LogToNativeLoggerEnv is used for those consumers like terraform that control the logs that are presented to the user, when this environment is turned on, the logger implementation will use the native Go logger 'log.Writer()'.
No description provided by the author
No description provided by the author