FAQ
`log.Println("blablabla")` will format all the message output to console,
but I want to show log information just in debug mode ;(

As far, I can do this to finish my job:

package main
import "log"
type mylog struct {}
func (m mylog) Write(p []byte) (n int, err error){return 0, nil}
func main(){
m := new(mylog)
log.SetOutput(m)
log.Println("this")
}


But it seems urgly.
Is there any good idea to output the log by the setting levels, just like
python:

logger.set_level(debug|warning|info|...) ?

--

Search Discussions

  • Kyle Lemons at Nov 6, 2012 at 6:44 pm
    Not with the standard logger.

    Shameless plug: I wrote a logging library that offers extensive
    customizability called log4go<http://go.pkgdoc.org/code.google.com/p/log4go>.
    There are many other alternatives *if* you actually need the functionality
    (which turns out to be less often than I thought when writing it).

    On Tue, Nov 6, 2012 at 5:42 AM, wrote:

    `log.Println("blablabla")` will format all the message output to console,
    but I want to show log information just in debug mode ;(

    As far, I can do this to finish my job:

    package main
    import "log"
    type mylog struct {}
    func (m mylog) Write(p []byte) (n int, err error){return 0, nil}
    func main(){
    m := new(mylog)
    log.SetOutput(m)
    log.Println("this")
    }


    But it seems urgly.
    Is there any good idea to output the log by the setting levels, just like
    python:

    logger.set_level(debug|warning|info|...) ?

    --

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 6, '12 at 3:05p
activeNov 6, '12 at 6:44p
posts2
users2
websitegolang.org

2 users in discussion

Soasme: 1 post Kyle Lemons: 1 post

People

Translate

site design / logo © 2023 Grokbase