import logging

TRACE = 5


class MyLogger(logging.getLoggerClass()):
        def __init__(self, name, level=logging.NOTSET):
            super(MyLogger, self).__init__(name, level)

            logging.addLevelName(TRACE, "TRACE")

        def trace(self, msg, *args, **kwargs):
            if self.isEnabledFor(TRACE):
                self._log(TRACE, msg, args, **kwargs)


logging.setLoggerClass(MyLogger)


def setup_logging(loglevel="info", logfile=None):
    from . import runtime_state

    if runtime_state.proc_rank != 0:
        return

    try: # python 2
        logging.basicConfig(logfile=logfile, filemode="w",
                            level=loglevel.upper(),
                            format="%(message)s")
    except ValueError: # python 3
        logging.basicConfig(filename=logfile, filemode="w",
                            level=loglevel.upper(),
                            format="%(message)s")

@@ -13,19 +13,8 @@
 ng%0A%0A
-TRACE = 5%0A%0A
 %0Acla
@@ -52,24 +52,35 @@
 ass()):%0A    
+TRACE = 5%0A%0A
     def __in
@@ -119,20 +119,16 @@
 OTSET):%0A
-    
         
@@ -171,21 +171,16 @@
  level)%0A
-%0A    
         
@@ -200,16 +200,25 @@
 velName(
+MyLogger.
 TRACE, %22
@@ -230,20 +230,16 @@
 %22)%0A%0A    
- 
-   
 def trac
@@ -277,20 +277,16 @@
         
-    
 if self.
@@ -302,16 +302,25 @@
 For(
+MyLogger.
 TRACE):%0A
     
@@ -315,20 +315,16 @@
 TRACE):%0A
-    
         
@@ -337,16 +337,25 @@
 lf._log(
+MyLogger.
 TRACE, m
@@ -531,16 +531,59 @@
 k != 0:%0A
+        logging.basicConfig(level=%22ERROR%22)%0A
         

set loglevel to error on workers