@@ -23,6 +23,7 @@ import argparse
2323import logging
2424import requests
2525import re
26+ import sys
2627from typing import List
2728import tempfile
2829
@@ -87,10 +88,10 @@ def parseArgs():
8788
8889def parseConfig (config_file_path ):
8990 """
90- Read the config file and prepare a list of rules.
91-
92- Return a dictionary containing the list of rules and other config elements from the file.
93-
91+ Read the config file and prepare a list of rules.
92+
93+ Return a dictionary containing the list of rules and other config elements from the file.
94+
9495 :param config_file_path: Path to the config file
9596 :raises yaml.YAMLError If the config file does not contain a valid yaml.
9697 """
@@ -206,11 +207,21 @@ def storeSavedTimestamp():
206207# ****************
207208
208209def main ():
209- # Logging (you can use funcName in the template)
210- logging .basicConfig (level = logging .INFO , format = '%(asctime)s - %(levelname)s - %(message)s' ,
211- datefmt = '%d-%b-%y %H:%M:%S' )
212-
213- # Parse arguments
210+ # Logging (split between stderr and stdout)
211+ formatter = logging .Formatter (fmt = '%(asctime)s - %(levelname)s - %(message)s' , datefmt = '%d-%b-%y %H:%M:%S' )
212+ h1 = logging .StreamHandler (sys .stdout )
213+ h1 .setLevel (logging .DEBUG )
214+ # filter out everything that is above INFO level (WARN, ERROR, ...)
215+ h1 .addFilter (lambda record : record .levelno <= logging .INFO )
216+ h1 .setFormatter (formatter )
217+ logging .getLogger ().addHandler (h1 )
218+ h2 = logging .StreamHandler (sys .stderr )
219+ # take only warnings and error logs
220+ h2 .setLevel (logging .WARNING )
221+ h2 .setFormatter (formatter )
222+ logging .getLogger ().addHandler (h2 )
223+
224+ # Parse arguments
214225 args = parseArgs ()
215226 logging .getLogger ().setLevel (int (args .log_level ))
216227
0 commit comments