Skip to content

Commit 9c974de

Browse files
committed
refine log format
1 parent deae044 commit 9c974de

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def get_test_config():
116116

117117
def unittest_main():
118118
config = get_test_config()
119-
logging.basicConfig(level=logging.WARNING)
119+
logging.basicConfig(level=logging.WARNING, format=constants.LOG_FORMAT)
120120
with utils.set_log_level(logging.getLogger(), logging.INFO) as logger:
121121
logger.info(config)
122122
unittest.main()

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import logging
77
from common import get_test_config
8-
from tf2onnx import utils
8+
from tf2onnx import constants, utils
99

1010

1111
def pytest_configure():
1212
config = get_test_config()
13-
logging.basicConfig(level=logging.WARNING)
13+
logging.basicConfig(level=logging.WARNING, format=constants.LOG_FORMAT)
1414
with utils.set_log_level(logging.getLogger(), logging.INFO) as logger:
1515
logger.info(config)

tests/run_pretrained_models.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@
2828
import yaml
2929

3030
import tf2onnx
31-
from tf2onnx import loader
32-
from tf2onnx import utils
33-
from tf2onnx import optimizer
31+
from tf2onnx import constants, loader, optimizer, utils
3432
from tf2onnx.tfonnx import process_tf_graph
3533

3634
# pylint: disable=broad-except,logging-not-lazy,unused-argument,unnecessary-lambda
3735

38-
logging.basicConfig(level=logging.INFO)
36+
logging.basicConfig(level=logging.INFO, format=constants.LOG_FORMAT)
3937
log = logging.getLogger("tf2onnx")
4038

4139
TEMP_DIR = os.path.join(utils.get_temp_directory(), "run_pretrained")

tf2onnx/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@
3232
NHWC_TO_NCHW = [0, 3, 1, 2]
3333
HWCN_TO_NCHW = [3, 2, 0, 1]
3434
NCHW_TO_HWCN = [2, 3, 1, 0]
35+
36+
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(name)s: %(message)s"

tf2onnx/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def default_custom_op_handler(ctx, node, name, args):
8080

8181
def main():
8282
args = get_args()
83-
logging.basicConfig(level=logging.INFO)
83+
logging.basicConfig(level=logging.INFO, format=constants.LOG_FORMAT)
8484

8585
# override unknown dimensions from -1 to 1 (aka batchsize 1) since not every runtime does
8686
# support unknown dimensions.

0 commit comments

Comments
 (0)