Skip to content

logging levels #13

@andycasey

Description

@andycasey

The documentation advises that:

Available levels are .debug, .info, .error, and .critical. For warnings, use warnings module.

But in fact logging an .error level does nothing, logging a .critical raises an exception (trace below), and there are leftovers from when "warnings" were available.

In [3]: log.critical("what")
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-3-53d8881f152d> in <module>()
----> 1 log.critical("what")

~/anaconda2/envs/py36/lib/python3.6/logging/__init__.py in critical(self, msg, *args, **kwargs)
   1351         """
   1352         if self.isEnabledFor(CRITICAL):
-> 1353             self._log(CRITICAL, msg, args, **kwargs)
   1354 
   1355     fatal = critical

~/anaconda2/envs/py36/lib/python3.6/logging/__init__.py in _log(self, level, msg, args, exc_info, extra, stack_info)
   1440         record = self.makeRecord(self.name, level, fn, lno, msg, args,
   1441                                  exc_info, func, extra, sinfo)
-> 1442         self.handle(record)
   1443 
   1444     def handle(self, record):

~/anaconda2/envs/py36/lib/python3.6/logging/__init__.py in handle(self, record)
   1450         """
   1451         if (not self.disabled) and self.filter(record):
-> 1452             self.callHandlers(record)
   1453 
   1454     def addHandler(self, hdlr):

~/anaconda2/envs/py36/lib/python3.6/logging/__init__.py in callHandlers(self, record)
   1512                 found = found + 1
   1513                 if record.levelno >= hdlr.level:
-> 1514                     hdlr.handle(record)
   1515             if not c.propagate:
   1516                 c = None    #break out

~/anaconda2/envs/py36/lib/python3.6/logging/__init__.py in handle(self, record)
    861             self.acquire()
    862             try:
--> 863                 self.emit(record)
    864             finally:
    865                 self.release()

~/research/projects/astra/python/astra/utils/logger.py in colored_formatter(record)
     95             message = '{} {}'.format(color_text(warning_text, ''), warning_category_colour)
     96 
---> 97     sys.__stdout__.write('{}{}\n'.format(header, message))
     98     sys.__stdout__.flush()
     99 

UnboundLocalError: local variable 'header' referenced before assignment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions