Skip to content
This repository was archived by the owner on Jul 19, 2026. It is now read-only.
ecnepsnaiPublic archive

About

Yet another go logging library

Topics

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Caution

github.com/ecnepsnai/logtic is deprecated and replaced by git.ecn.io/ian/logtic. All users should migrate to git.ecn.io/ian/logtic for continued updates. Tag v1.0.0 is drop-in compatible copy of the last release of github.com/ecnepsnai/logtic.

logtic

Go Report Card Godoc Releases LICENSE

Logtic is a yet another logging library for golang projects.

The goal of logtic is to be as transparent and easy to use as possible, allowing applications and libraries to seamlessly log to a single file. Logtic can be used in libraries and won't cause any problems if the parent application isn't using logtic.

Logtic supports multiple sources, which annotate the outputted log lines. It also supports defining a minimum desired log level, which can be changed at any time. Events printed to the terminal output support color-coded severities.

Events can be printed as formatted strings, like with fmt.Printf, or can be parameterized events which can be easily parsed by log analysis tools such as Splunk.

By default, logtic will only print to stdout and stderr, but when configured it can also write to a log file. Log files include the date-time for each event in RFC-3339 format.

Logtic provides a default logging instance but also supports unique instances that can operate in parallel, writing to unique files and having unique settings.

Log files can be rotated using the provided rotate method.

Usage & Examples

For more examples please refer to the official documentation

Basic Log File

var log *logtic.Source

func init() {
    logtic.Log.FilePath = "./app.log"
    logtic.Log.Level = logtic.LevelInfo
}

func main() {
    if err := logtic.Open(); err != nil {
        // There was an error opening the log file for writing
        panic(err)
    }
    log = logtic.Connect("MyApp")
    log.Info("This is an %s message", "informational")
    defer logtic.Close()
}

Console-Only (No Log File)

var log *logtic.Source

func main() {
    // By default, calling logtic.Open without changing anything
    // will open a console-only log file
    logtic.Open()
    log = logtic.Connect("MyApp")
    log.Info("This is an %s message", "informational")
}

Writing Events

Logtic uses "sources", which can be thought of like Classes in traditional OOP. Log entries are annotated with the name.

For example, if you have two unique goroutines that you want to easily identify in logs, you can give each routine a source with a unique name.

log := logtic.Connect("MyCoolApplication")
log.Info("Print something %s", "COOL!")
// Output: [INFO][MyCoolApplication] Print something COOL!

About

Yet another go logging library

Topics

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages