Coder Social home page Coder Social logo

Logger message appears twice about sos HOT 2 CLOSED

vatlab avatar vatlab commented on August 30, 2024
Logger message appears twice

from sos.

Comments (2)

BoPeng avatar BoPeng commented on August 30, 2024

I do not see this problem from test_utils.

    # create a logger, but shutdown the previous one
    if self._logger is not None:
        self._logger.handlers = []

is supposed to avoid this but I might have overlooked something.

Bo

On Wed, Mar 9, 2016 at 11:47 PM, gaow [email protected] wrote:

When I use env.logger from pysos.utils the logging message always appear
twice. I remember I must have run into this before but I cannot recall the
way out. I had to add if not self._logger.handlers to get rid of the
duplicate, based on a random stackoverflow.com post. I am not sure if the
problem occurs in the current SoS -- since I only used the
RuntimeEnvironment class in my application something might be different,
and the patch below is obviously not good because there are two types of
handler cout and ch and I'm not dealing with it properly. Just want to
know if this is an issue before taking any other actions.

  •    cout = logging.StreamHandler()-        levels = {-            '0': logging.WARNING,-            '1': logging.INFO,-            '2': logging.DEBUG,-            '3': logging.TRACE,-            None: logging.INFO-        }-        #-        cout.setLevel(levels[self._verbosity])-        cout.setFormatter(ColoredFormatter('%(color_levelname)s: %(color_msg)s'))-        self._logger.addHandler(cout)+        if not self._logger.handlers:+            cout = logging.StreamHandler()+            levels = {+                '0': logging.WARNING,+                '1': logging.INFO,+                '2': logging.DEBUG,+                '3': logging.TRACE,+                None: logging.INFO+            }+            #+            cout.setLevel(levels[self._verbosity])+            cout.setFormatter(ColoredFormatter('%(color_levelname)s: %(color_msg)s'))+            self._logger.addHandler(cout)
    


Reply to this email directly or view it on GitHub
#2.

from sos.

gaow avatar gaow commented on August 30, 2024

It turns out I have imported like this in my test script:

from dsc import DSCData
utils import env

and in DSCData I also used env. There must then be a conflict. After I fixed python 3 compatibility and installed SOS, the following works:

from dsc import DSCData
from pysos.utils import env

So there will not be a problem if the package is properly installed.

from sos.

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.