Skip to content
This repository has been archived by the owner on Dec 3, 2017. It is now read-only.
/ gologit Public archive

[deprecated] simple go logging wrapper with debug flag support

License

Notifications You must be signed in to change notification settings

cactus/gologit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gologit

A simple wrapper for Go "log" that provides toggle-able debug support.

NOTE: gologit is currently deprecated. Check out mlog instead.

Installation

$ go get github.com/cactus/gologit

Usage

Simplest:

import (
    "flag"
    "github.com/cactus/gologit"
)

func main() {
    debug := flag.Bool("debug", false, "Enable Debug Logging")
    flag.Parse()

    // set debug true/false
    gologit.Logger.Set(*debug)
    // this prints only if debug is true
    gologit.Logger.Debugln("Debug Logging enabled!")
}

Simple:

import (
    "flag"
    "github.com/cactus/gologit"
)

// alias exported gologit Logger to a short name for convenience
var logger = gologit.Logger

func main() {
    debug := flag.Bool("debug", false, "Enable Debug Logging")
    flag.Parse()

    logger.Set(*debug)
    logger.Debugln("Logging enabled")
}

When you don't want to share:

import (
    "flag"
    "github.com/cactus/gologit"
)

// make a new one (unique to this module)
var logger = gologit.New(false)

func main() {
    debug := flag.Bool("debug", false, "Enable Debug Logging")
    flag.Parse()

    logger.Set(*debug)
    logger.Debugln("Logging enabled")
}

Pass it like a logging potato:

import (
    "flag"
    "github.com/cactus/gologit"
)

// make a new one (unique to this module)
var logger = gologit.New(false)

func main() {
    debug := flag.Bool("debug", false, "Enable Debug Logging")
    flag.Parse()

    logger := gologit.New(*debug)
    logger.Debugln("Logging enabled")
    SomeOtherFunc(logger)
}

Documentation

More documentation available at go.pkgdoc.org

License

Released under the MIT license. See LICENSE file for details.

About

[deprecated] simple go logging wrapper with debug flag support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages