Giter VIP home page Giter VIP logo

Comments (5)

inconshreveable avatar inconshreveable commented on June 24, 2024

Ouch, yeah, that's quite possible. What type of terminal were you using, cmd.exe or Powershell, or one of the other variants? For now, I'd suggest you do something like:

if runtime.GOOS == "windows" {
    log.Root().SetHandler(log.StreamHandler(os.Stdout, log.LogfmtFormat()))
}

from log15.

karalabe avatar karalabe commented on June 24, 2024

I usually use Linux, was just investigating a crash report in windows, so I've got nothing fancy installed, just cmd.exe.

I was also thinking about some similar solution, but since I'm using this in a library (https://github.com/project-iris/iris-go#logging) where anybody can override the default log settings, is there a way to "force" colorless logging even if the user changes some of the settings? (I'm not familiar with the log15 internals, hence my question :) ).

from log15.

inconshreveable avatar inconshreveable commented on June 24, 2024

You can force colorless logging with this code:

log.Root().SetHandler(log.StreamHandler(os.Stdout, log.LogfmtFormat()))

By default, when log15 init()'s, it checks if os.Stdout is a terminal, and if it is, uses log.TerminalFormat() which does the color formatting. Explicitly setting it to LogfmtFormat() or JsonFormat() will force no colorization.

from log15.

ChrisHines avatar ChrisHines commented on June 24, 2024

What about using the recently announced github.com/mattn/go-colorable package to get color for Windows too?

from log15.

inconshreveable avatar inconshreveable commented on June 24, 2024

thanks for pointing that out! i'm going to take a look at using mattn's package for this

from log15.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.