Skip to content

Commit

Permalink
Add logging configuration (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
echeran authored Nov 18, 2023
1 parent 83c3ca7 commit 750f684
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ testdriver/.local-chrome/
testgen/*.json

TEMP_DATA/*

debug.log*
33 changes: 33 additions & 0 deletions logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[loggers]
keys=root

[logger_root]
handlers=screen,file
level=NOTSET

[formatters]
keys=simple,complex

[formatter_simple]
format=[%(asctime)s] [%(levelname)s] %(message)s

[formatter_complex]
format=[%(asctime)s,%(module)s:%(lineno)d] [%(levelname)s] %(message)s

[handlers]
keys=file,screen

[handler_file]
class=handlers.TimedRotatingFileHandler
interval=midnight
backupCount=5
formatter=complex
level=DEBUG
# equivalent to: 'debug.log', when='S', interval=10, backupCount=5
args=('debug.log', 'S', 10, 5)

[handler_screen]
class=StreamHandler
formatter=simple
level=INFO
args=(sys.stdout,)
3 changes: 3 additions & 0 deletions schema/check_generated_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


import logging
import logging.config
import os.path
import sys

Expand All @@ -16,6 +17,8 @@
from schema_files import ALL_TEST_TYPES

def main(args):
logging.config.fileConfig("../logging.conf")

if len(args) <= 1:
logging.error('Please specify the path to test data directory')
return
Expand Down
2 changes: 2 additions & 0 deletions schema/check_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


import logging
import logging.config
import os.path
import sys

Expand All @@ -16,6 +17,7 @@
class ValidateSchema():
def __init__(self, schema_base='.'):
self.schema_base = schema_base
logging.config.fileConfig("../logging.conf")

def save_schema_validation_summary(self, validation_status):

Expand Down
3 changes: 3 additions & 0 deletions schema/check_test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


import logging
import logging.config
import os.path
import sys

Expand All @@ -17,6 +18,8 @@
from schema_files import ALL_TEST_TYPES

def main(args):
logging.config.fileConfig("../logging.conf")

if len(args) <= 1:
logging.error('Please specify the path to the test output directory')
exit(1)
Expand Down
5 changes: 4 additions & 1 deletion schema/schema_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from jsonschema import exceptions

import logging
import logging.config
import os.path
import sys

Expand All @@ -33,6 +34,8 @@ def __init__(self):
self.icu_versions = []
self.debug_leve = 0

logging.config.fileConfig("../logging.conf")

def validate_json_file(self, schema_file_path, data_file_path):
# Returns True, None if data is validated against the schema
# returns Falee, error_string if there's a problem
Expand Down Expand Up @@ -139,7 +142,7 @@ def check_test_data_schema(self, icu_version, test_type):
test_result = result
results['result'] = result
if result:
logging.info('Test data %s validated with %s, ICU %s', test_type, icu_version)
logging.info('Test data %s validated successfully, with ICU %s', test_type, icu_version)
else:
logging.error('Test data %s FAILED with ICU %s: %s', test_type, icu_version, err_info)

Expand Down
4 changes: 4 additions & 0 deletions testdriver/testdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime
import json
import logging
import logging.config
import os
import subprocess
import sys
Expand All @@ -24,6 +25,9 @@ def __init__(self):
self.icuVersion = None
self.test_plans = []
self.debug = False

logging.config.fileConfig("../logging.conf")

return

def set_args(self, arg_options):
Expand Down
3 changes: 3 additions & 0 deletions testdriver/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
import json
import logging
import logging.config
import os
import subprocess
import sys
Expand Down Expand Up @@ -53,6 +54,8 @@ def __init__(self, exec_data, test_type, args=None):

self.verifier = None

logging.config.fileConfig("../logging.conf")

def set_options(self, options):
self.options = options
try:
Expand Down
3 changes: 3 additions & 0 deletions testgen/testdata_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import json
import logging
import logging.config
import math
import os
import re
Expand All @@ -26,6 +27,8 @@ def __init__(self, icu_version):
# If set, this is the maximum number of tests generated for each.
self.run_limit = None

logging.config.fileConfig("../logging.conf")

def setVersion(self, selected_version):
self.icu_version = selected_version

Expand Down
3 changes: 3 additions & 0 deletions verifier/report_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
import glob
import json
import logging
import logging.config
from string import Template
import sys

class reportTemplate():
def __init__(self):
logging.config.fileConfig("../logging.conf")

# Read the template data
detail_template = ''
filename = 'detail_template.html'
Expand Down
7 changes: 7 additions & 0 deletions verifier/testreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import glob
import json
import logging
import logging.config
import os
from string import Template
import sys
Expand Down Expand Up @@ -46,6 +47,8 @@ def __init__(self):

self.params_diff = {}

logging.config.fileConfig("../logging.conf")

def add_diff(self, num_diffs, diff_list, last_diff):
# Record single character differences
if num_diffs == 1:
Expand Down Expand Up @@ -127,6 +130,8 @@ def __init__(self, report_path, report_html_path):

self.test_unsupported_template = templates.test_unsupported_template

logging.config.fileConfig("../logging.conf")

def set_title(self, executor, result_version, test_type):
self.title = 'Test %s executed on %s with data %s' % (test_type, executor, result_version)

Expand Down Expand Up @@ -863,6 +868,8 @@ def __init__(self, file_base):
'<td>$report_detail</td>'
)

logging.config.fileConfig("../logging.conf")

def get_json_files(self):
# For each executor directory in testReports,
# Get each json report file
Expand Down
3 changes: 3 additions & 0 deletions verifier/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import json
import logging
import logging.config
import os
import shutil
import sys
Expand Down Expand Up @@ -62,6 +63,8 @@ def __init__(self):
# Filename used for the json version of verifier output
self.report_filename = VERIFIER_REPORT_NAME

logging.config.fileConfig("../logging.conf")

def open_verify_files(self):
# Get test data, verify data, and results for a case.
try:
Expand Down

0 comments on commit 750f684

Please sign in to comment.