Skip to content

Commit

Permalink
logging section improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Loevenich, Mathis committed Jul 17, 2020
1 parent dd55f02 commit 479733d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions script/htcompact
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,9 @@ def setup_logging_tool(log_file=sys.argv[0]+'.log'):
:return:
"""

# disable the loggeing tool by default
logging.getLogger().disabled = True

# if logging tool is set to use
if generate_log_file:
logging.getLogger().disabled = False
Expand All @@ -2451,13 +2454,16 @@ def setup_logging_tool(log_file=sys.argv[0]+'.log'):
logging_file_format = '%(asctime)s - [%(funcName)s:%(lineno)d] %(levelname)s : %(message)s'
file_formatter = logging.Formatter(logging_file_format)

handler = RotatingFileHandler(log_file, maxBytes=1024)
handler = RotatingFileHandler(log_file, maxBytes=1000000, backupCount=1)
handler.setLevel(logging.DEBUG)
handler.setFormatter(file_formatter)

log = logging.getLogger()
log.setLevel(logging.DEBUG)
log.addHandler(handler)
# os.system("tail -n 10 htcompact.log > htcompact_tmp.log")
# os.system("cat htcompact_tmp.log > htcompact.log")
# os.system("rm htcompact_tmp.log")

if verbose_mode:
# activate logger if not already activated
Expand Down Expand Up @@ -2586,8 +2592,6 @@ if __name__ == "__main__":
:return:
"""
try:
# disable the loggeing tool by default
logging.getLogger().disabled = True

initialize()

Expand Down

0 comments on commit 479733d

Please sign in to comment.