File = ""
Yes = False
+LOGGING_NOTICE = int((logging.INFO + logging.WARNING) / 2)
+
class DebugFormatter(logging.Formatter):
def format(self, record):
if record.levelno == logging.DEBUG:
logging.CRITICAL: "\x1b[35;1m",
logging.ERROR: "\x1b[33;1m",
logging.WARNING: "\x1b[33;1m",
+ LOGGING_NOTICE: "\x1b[0m",
logging.INFO: "\x1b[0m",
logging.DEBUG: "\x1b[30;1m",
logging.NOTSET: "\x1b[30;1m"
bufsize=(4 << 20),
stdin=subprocess.PIPE,
stdout=None, stderr=None)
- logging.info(f"Writing {name} to {pdevice}")
+ logging.notice(f"Writing {name} to {pdevice}")
buf = f.read(4 << 20)
while len(buf) > 0:
proc_dd.stdin.write(buf)
if target.with_super:
do_fuse_image_super(tmpd, target)
+def logger_notice(self, msg, *args, **kws):
+ if self.isEnabledFor(LOGGING_NOTICE):
+ self._log(LOGGING_NOTICE, msg, args, **kws)
+logging.Logger.notice = logger_notice
+
+def logging_notice(msg, *args, **kws):
+ if len(logging.root.handlers) == 0:
+ basicConfig()
+ logging.root.notice(msg, *args, **kws)
+logging.notice = logging_notice
+
+
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="For {}, version {}".format(
", ".join([v.long_name for k,v in TARGETS.items()]),
parser.add_argument("--create", action="store_true",
help="create the backing file and format the loopback device")
parser.add_argument("--debug", action="store_const", const="debug",
- default="warning", dest="log_level",
+ default="notice", dest="log_level",
help="set log level to DEBUG")
parser.add_argument("-d", "--device",
help="device node or loopback backing file")
parser.add_argument("--format", action="store_true",
help="create new partition table on the target device")
- parser.add_argument("--log-level", dest="log_level", default="warning",
- help="Verbosity, possible values: debug, info, warning, "
- "error, critical (default: warning)")
+ parser.add_argument("--log-level", dest="log_level", default="notice",
+ help="Verbosity, possible values: debug, info, notice, warning, "
+ "error, critical (default: notice)")
parser.add_argument("--partition-size", type=str, action="extend", dest="partition_sizes",
nargs='*',
help="override default partition size (in MiB) (used with --format), "
parser.error('--partition-size must follow the name=size pattern')
args.partition_sizes = partition_sizes
+ logging.addLevelName(LOGGING_NOTICE, "NOTICE")
conh = ColorStreamHandler(format='%(asctime)s.%(msecs)d %(debuginfo)s%(levelname)-8s %(message)s',
cformat='%(asctime)s.%(msecs)d %(debuginfo)s%(levelcolor)s%(message)s',
datefmt='%Y-%m-%dT%H:%M:%S')