Giter Site home page Giter Site logo

Comments (7)

borntyping avatar borntyping commented on August 16, 2024 1

If you wanted to make a PR for this, I'd suggest looking at merging the functionality from TTYColoredFormatter into ColoredFormatter and adding a parameter that toggled it. The TTYColoredFormatter could then be simplified into a class that just sets that parameter.

from python-colorlog.

naggie avatar naggie commented on August 16, 2024

Have you tried colorlog.TTYColoredFormatter? This should disable the codes if not running inside a TTY.

from python-colorlog.

buhtz avatar buhtz commented on August 16, 2024

Oh, I wasn't aware of that class. Great. Haven't tried it yet but I think this will fix the problem.

from python-colorlog.

buhtz avatar buhtz commented on August 16, 2024

It is not working with Thonny-IDE under Windows10. Looking at stackoverflow I can see there is no generalizable solution for that problem.

os.environ give some hints, too.

from python-colorlog.

borntyping avatar borntyping commented on August 16, 2024

You're probably better off just configuring a different formatter on Windows machines, with something like the following:

import platform
import logging
import colorlog

handler = logging.StreamHandler()
if platform.system() == 'Windows':
     handler.setFormatter(colorlog.ColoredFormatter('%(log_color)s%(levelname)s:%(name)s:%(message)s'))
else:
     handler.setFormatter(logging.Formatter('%(levelname)s:%(name)s:%(message)s'))

logger = colorlog.getLogger('example')
logger.addHandler(handler)

from python-colorlog.

buhtz avatar buhtz commented on August 16, 2024

It is a workaround but not a solution for this Issue. :)

from python-colorlog.

eblis avatar eblis commented on August 16, 2024

This issue doesn't mention this but now you can disable colors by setting the no_color flag to True.

I was about to create a MR but noticed that the functionality is already there :)

from python-colorlog.

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.