Skip to content
A simple logger. No dependencies, no special features, just logging.
Go
Branch: master
Clone or download

Latest commit

Latest commit 1d27ffc Mar 23, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
images
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md docs: add code of conduct and contrib guide lines Mar 18, 2020
LICENSE Update LICENSE Mar 19, 2020
README.md
go.mod Create project Mar 17, 2020
simplog.go
simplog_test.go test: add test for New Mar 18, 2020

README.md

proji logo

Go Report Card Codacy Badge Maintainability Actions Status go.dev reference

A simple logger. No dependencies, no special features, just logging.

About

Simplog was created due to the unsuccessful search for a small and simple logging system. I needed a system that's exactly in the middle between 'does-what-it-should' and 'no-overkill'. Besides that I just wanted to write a logging library myself for fun.

If you like it and/or if it is useful for you, it has already more than fulfilled its purpose. Contributions are still welcome but just remember that this logger is intentionally kept simple.

Install

go get -u github.com/nikoksr/simplog

Example Code

// Open log file
logPath := "simple.log"

f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
	log.Fatalf("could not open log file %s. %v", logPath, err)
}

// Create logger
var log = simplog.New("Core", false, f)
if err != nil {
    log.Fatalf("could not create logger %v", err)
}

// Set log level to warning
log.SetLevel(simplog.Warning)

// fmt.Print style
log.Info("You're awesome!\n")

// fmt.Println style
log.Warningln("Coffee is almost empty.")

// fmt.Printf style
log.Debugf("%d should be equal to %d.\n", aNumber, anotherNumber)

Example Output

CORE 2020/03/18 17:13:24 main.go:24: INFO You're awesome!
CORE 2020/03/18 17:13:24 main.go:26: WARN Coffee is almost empty.
CORE 2020/03/18 17:13:25 main.go:28: DEBUG 17 should be equal to 9.

Credits

You can’t perform that action at this time.