Skip to content

Logger provides standard logging methods around the standard log package.

License

Notifications You must be signed in to change notification settings

cloud-spin/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logger Build Status codecov Go Report Card GoDoc

Package logger provides standard logging methods around the standard log package. Each logged line is prefixed with the logging level (Debug, Info, Warn, ...). The Enabled and Level configurations are respected every time the logging methods are called. Logger provides a Logger interface for easy mocking and also an OnLog handler to help identify logged data in unit tests.

Install

From a configured Go environment:

go get -u github.com/cloud-spin/logger

If you are using dep:

dep ensure -add github.com/cloud-spin/logger

How to Use

Below example starts a enabled logger to Info level and logs a Info message with one parameter.

package main

import (
	"fmt"

	"github.com/cloud-spin/logger"
)

func main() {
	configs := &logger.Configs{
		Enabled: true,
		Level:   logger.LevelInfo,
	}
	logger, err := logger.New(configs)
	if err != nil {
		fmt.Printf("Expected: logger initialized; Got: %s", err.Error())
	}

	logger.Info("Info message with '%s' param", "string")
}

Output:

[INFO] 2018/09/10 11:20:11 Info message with 'string' param

Also refer to the tests at logger_test.go.

License

MIT, see LICENSE.

"Use, abuse, have fun and contribute back!"

Contributions

See contributing.md.

About

Logger provides standard logging methods around the standard log package.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages