|
@@ -35,6 +35,7 @@ import inspect
|
|
import logging
|
|
import logging
|
|
import sys
|
|
import sys
|
|
|
|
|
|
|
|
+
|
|
def setup_logging(args, stream=None):
|
|
def setup_logging(args, stream=None):
|
|
"""setup logging module according to the arguments provided
|
|
"""setup logging module according to the arguments provided
|
|
|
|
|
|
@@ -46,16 +47,18 @@ def setup_logging(args, stream=None):
|
|
sh = logging.StreamHandler(stream)
|
|
sh = logging.StreamHandler(stream)
|
|
# other formatters will probably want this, but let's remove
|
|
# other formatters will probably want this, but let's remove
|
|
# clutter on stderr
|
|
# clutter on stderr
|
|
- #sh.setFormatter(logging.Formatter('%(name)s: %(message)s'))
|
|
|
|
|
|
+ # example:
|
|
|
|
+ # sh.setFormatter(logging.Formatter('%(name)s: %(message)s'))
|
|
l.addHandler(sh)
|
|
l.addHandler(sh)
|
|
- levels = { None: logging.WARNING,
|
|
|
|
- 0: logging.WARNING,
|
|
|
|
- 1: logging.INFO,
|
|
|
|
- 2: logging.DEBUG }
|
|
|
|
|
|
+ levels = {None: logging.WARNING,
|
|
|
|
+ 0: logging.WARNING,
|
|
|
|
+ 1: logging.INFO,
|
|
|
|
+ 2: logging.DEBUG}
|
|
# default to WARNING, -v goes to INFO and -vv to DEBUG
|
|
# default to WARNING, -v goes to INFO and -vv to DEBUG
|
|
l.setLevel(levels[args.verbose])
|
|
l.setLevel(levels[args.verbose])
|
|
return sh,
|
|
return sh,
|
|
|
|
|
|
|
|
+
|
|
def find_parent_module():
|
|
def find_parent_module():
|
|
"""find the name of a the first module calling this module
|
|
"""find the name of a the first module calling this module
|
|
|
|
|
|
@@ -74,6 +77,7 @@ def find_parent_module():
|
|
# return the logger module name by default
|
|
# return the logger module name by default
|
|
return __name__
|
|
return __name__
|
|
|
|
|
|
|
|
+
|
|
def create_logger(name=None):
|
|
def create_logger(name=None):
|
|
"""create a Logger object with the proper path, which is returned by
|
|
"""create a Logger object with the proper path, which is returned by
|
|
find_parent_module() by default, or is provided via the commandline
|
|
find_parent_module() by default, or is provided via the commandline
|