[yt-svn] commit/yt: chummels: Merged in jzuhone/yt-3.x (pull request #1355)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Dec 12 12:16:00 PST 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/85c080fca437/
Changeset:   85c080fca437
Branch:      yt
User:        chummels
Date:        2014-12-12 20:15:46+00:00
Summary:     Merged in jzuhone/yt-3.x (pull request #1355)

[bugfix] More consistent behavior for the logger, mentioning OS X 10.10 in the install script
Affected #:  3 files

diff -r bca4a0577dde3e1d7c5c0ac369b67d29669e8a7f -r 85c080fca437391085be47f6c23583f94283a37a doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -264,8 +264,8 @@
         echo "Alternatively, download the Xcode command line tools from"
         echo "the Apple developer tools website."
         echo
-	echo "OS X 10.8.4 and 10.9: download Xcode 5.02 from the mac app store."
-	echo "(search for Xcode)."
+	echo "OS X 10.8.4, 10.9, and 10.10: download the appropriate version of 
+	echo "Xcode from the mac app store (search for Xcode)."
     echo
 	echo "Additionally, you will have to manually install the Xcode"
 	echo "command line tools."
@@ -273,7 +273,7 @@
     echo "For OS X 10.8, see:"
    	echo "http://stackoverflow.com/questions/9353444"
 	echo
-    echo "For OS X 10.9, the command line tools can be installed"
+    echo "For OS X 10.9 and 10.10, the command line tools can be installed"
     echo "with the following command:"
     echo "    xcode-select --install"
     echo

diff -r bca4a0577dde3e1d7c5c0ac369b67d29669e8a7f -r 85c080fca437391085be47f6c23583f94283a37a doc/source/reference/faq/index.rst
--- a/doc/source/reference/faq/index.rst
+++ b/doc/source/reference/faq/index.rst
@@ -148,6 +148,47 @@
 
 .. _faq-mpi4py:
 
+How can I change yt's log level? 
+--------------------------------
+
+yt's default log level is ``INFO``. However, you may want it to shut up, especially
+if you are in an IPython notebook or running a long or parallel script. On the other
+hand, you may want it to speak up, since you can't figure out exactly what's going 
+wrong, and you want to output some debugging information. The yt log level can be 
+changed using the :ref:`configuration`, either by setting it in the ``$HOME/.yt/config``
+file:
+
+.. code-block:: bash
+
+   [yt]
+   loglevel = 10 # This sets the log level to "DEBUG"
+   
+which would produce debug (as well as info, warning, and error) messages, or at runtime:
+
+.. code-block:: python
+
+   from yt.config import ytcfg
+   ytcfg["yt","loglevel"] = "40" # This sets the log level to "ERROR"
+   
+which in this case would suppress everything below error messages. For reference, the numerical 
+values corresponding to different log levels are:
+
++----------+---------------+
+| Level    | Numeric Value |
++==========+===============+
+| CRITICAL | 50            |
++----------+---------------+
+| ERROR	   | 40            |
++----------+---------------+
+| WARNING  | 30            |
++----------+---------------+
+| INFO	   | 20            |
++----------+---------------+
+| DEBUG	   | 10            |
++----------+---------------+
+| NOTSET   | 0             |
++----------+---------------+
+
 yt complains that it needs the mpi4py module
 --------------------------------------------
 
@@ -322,3 +363,4 @@
       adsurl = {http://adsabs.harvard.edu/abs/2010ApJS..191...43S},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
    }
+

diff -r bca4a0577dde3e1d7c5c0ac369b67d29669e8a7f -r 85c080fca437391085be47f6c23583f94283a37a yt/utilities/logger.py
--- a/yt/utilities/logger.py
+++ b/yt/utilities/logger.py
@@ -25,7 +25,7 @@
 def add_coloring_to_emit_ansi(fn):
     # add methods we need to the class
     def new(*args):
-        levelno = args[1].levelno
+        levelno = args[0].levelno
         if(levelno >= 50):
             color = '\x1b[31m'  # red
         elif(levelno >= 40):
@@ -38,8 +38,8 @@
             color = '\x1b[35m'  # pink
         else:
             color = '\x1b[0m'  # normal
-        ln = color + args[1].levelname + '\x1b[0m'
-        args[1].levelname = ln
+        ln = color + args[0].levelname + '\x1b[0m'
+        args[0].levelname = ln
         return fn(*args)
     return new
 
@@ -52,39 +52,33 @@
 else:
     stream = sys.stderr
 
-logging.basicConfig(
-    format=ufstring,
-    level=level,
-    stream=stream,
-)
-
-rootLogger = logging.getLogger()
 ytLogger = logging.getLogger("yt")
 
+yt_sh = logging.StreamHandler(stream=stream)
+# create formatter and add it to the handlers
+formatter = logging.Formatter(ufstring)
+yt_sh.setFormatter(formatter)
+# add the handler to the logger
+ytLogger.addHandler(yt_sh)
+ytLogger.setLevel(level)
+ytLogger.propagate = False
+ 
 def disable_stream_logging():
-    # We just remove the root logger's handlers
-    for handler in rootLogger.handlers:
-        if isinstance(handler, logging.StreamHandler):
-            rootLogger.removeHandler(handler)
+    ytLogger.removeHandler(ytLogger.handlers[0])
     h = logging.NullHandler()
     ytLogger.addHandler(h)
 
-original_emitter = logging.StreamHandler.emit
-
+original_emitter = yt_sh.emit
 
 def colorize_logging():
     f = logging.Formatter(cfstring)
-    if len(rootLogger.handlers) > 0:
-        rootLogger.handlers[0].setFormatter(f)
-    logging.StreamHandler.emit = add_coloring_to_emit_ansi(
-        logging.StreamHandler.emit)
-
+    ytLogger.handlers[0].setFormatter(f)
+    yt_sh.emit = add_coloring_to_emit_ansi(yt_sh.emit)
 
 def uncolorize_logging():
     f = logging.Formatter(ufstring)
-    if len(rootLogger.handlers) > 0:
-        rootLogger.handlers[0].setFormatter(f)
-    logging.StreamHandler.emit = original_emitter
+    ytLogger.handlers[0].setFormatter(f)
+    yt_sh.emit = original_emitter
 
 if ytcfg.getboolean("yt", "coloredlogs"):
     colorize_logging()

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list