Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Save the original format configured by the user
# when the logger formatter was instantiated
format_orig = self._fmt
# Replace the original format with one customized by logging level
if record.levelno == logging.DEBUG:
self._fmt = LogFormatter.dbg_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.WARNING:
self._fmt = LogFormatter.warn_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.INFO:
self._fmt = LogFormatter.info_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.ERROR:
self._fmt = LogFormatter.err_fmt
self._style = logging.PercentStyle(self._fmt)
# Call the original formatter class to do the grunt work
result = logging.Formatter.format(self, record)
# Restore the original format configured by the user
self._fmt = format_orig
return result
def main():
# set up the basic logging configuration
formatter = LogFormatter()
# we need two handlers, one that prints to stdout
# for the "run" command and one that prints to stderr
# from the "generate" command; the latter is necessary
# because do not want the warning to show up in the
# generated configuration file
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(formatter)
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setFormatter(formatter)
logging.root.setLevel(logging.INFO)
logger = logging.getLogger(__name__)
# set up an argument parser via our helper function
def main():
# set up the basic logging configuration
formatter = LogFormatter()
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
logging.root.addHandler(handler)
logging.root.setLevel(logging.INFO)
# get the logger
logger = logging.getLogger(__name__)
# set up an argument parser
parser = argparse.ArgumentParser(prog='rsmsummarize')
parser.add_argument('-f', '--force', dest='force_write',
action='store_true', default=False,
help="If true, rsmsummarize will not check if the"
def main():
# set up the basic logging configuration
formatter = LogFormatter()
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
logging.root.addHandler(handler)
logging.root.setLevel(logging.INFO)
# get a logger
logger = logging.getLogger(__name__)
# set up an argument parser
parser = argparse.ArgumentParser(prog='rsmeval')
parser.add_argument('-f', '--force', dest='force_write',
action='store_true', default=False,
help="If true, rsmtool will not check if the"
# Replace the original format with one customized by logging level
if record.levelno == logging.DEBUG:
self._fmt = LogFormatter.dbg_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.WARNING:
self._fmt = LogFormatter.warn_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.INFO:
self._fmt = LogFormatter.info_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.ERROR:
self._fmt = LogFormatter.err_fmt
self._style = logging.PercentStyle(self._fmt)
# Call the original formatter class to do the grunt work
result = logging.Formatter.format(self, record)
# Restore the original format configured by the user
self._fmt = format_orig
return result
def main():
# set up the basic logging configuration
formatter = LogFormatter()
# we need two handlers, one that prints to stdout
# for the "run" command and one that prints to stderr
# from the "generate" command; the latter is important
# because do not want the warning to show up in the
# generated configuration file
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(formatter)
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setFormatter(formatter)
logging.root.setLevel(logging.INFO)
logger = logging.getLogger(__name__)
# set up an argument parser via our helper function
----------
record
The record to format
"""
# Save the original format configured by the user
# when the logger formatter was instantiated
format_orig = self._fmt
# Replace the original format with one customized by logging level
if record.levelno == logging.DEBUG:
self._fmt = LogFormatter.dbg_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.WARNING:
self._fmt = LogFormatter.warn_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.INFO:
self._fmt = LogFormatter.info_fmt
self._style = logging.PercentStyle(self._fmt)
elif record.levelno == logging.ERROR:
self._fmt = LogFormatter.err_fmt
self._style = logging.PercentStyle(self._fmt)
# Call the original formatter class to do the grunt work
result = logging.Formatter.format(self, record)
# Restore the original format configured by the user
self._fmt = format_orig
def main():
# set up the basic logging configuration
formatter = LogFormatter()
# we need two handlers, one that prints to stdout
# for the "run" command and one that prints to stderr
# from the "generate" command; the latter is important
# because do not want the warning to show up in the
# generated configuration file
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(formatter)
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setFormatter(formatter)
logging.root.setLevel(logging.INFO)
logger = logging.getLogger(__name__)
# set up an argument parser via our helper function