Skip to content

Commit

Permalink
Replace coloredlogs usage in matter_idl with just basicConfig. (#26376)
Browse files Browse the repository at this point in the history
This makes the dependencies of matter_idl even smaller, generally
only lark and click.

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 25, 2023
1 parent 4d74704 commit 7896c23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ def CreateParser(file_name: str):
# This Parser is generally not intended to be run as a stand-alone binary.
# The ability to run is for debug and to print out the parsed AST.
import click
import coloredlogs

# Supported log levels, mapping string values required for argument
# parsing into logging constants
Expand All @@ -318,8 +317,10 @@ def CreateParser(file_name: str):
help='Determines the verbosity of script output.')
@click.argument('filename')
def main(log_level, filename=None):
coloredlogs.install(level=__LOG_LEVELS__[
log_level], fmt='%(asctime)s %(levelname)-7s %(message)s')
logging.basicConfig(
level=__LOG_LEVELS__[log_level],
format='%(asctime)s %(levelname)-7s %(message)s',
)

logging.info("Starting to parse ...")
data = CreateParser(filename).parse()
Expand Down
7 changes: 4 additions & 3 deletions scripts/py_matter_idl/matter_idl/matter_idl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ def CreateParser(skip_meta: bool = False):
import pprint

import click
import coloredlogs

# Supported log levels, mapping string values required for argument
# parsing into logging constants
Expand All @@ -560,8 +559,10 @@ def CreateParser(skip_meta: bool = False):
help='Determines the verbosity of script output.')
@click.argument('filename')
def main(log_level, filename=None):
coloredlogs.install(level=__LOG_LEVELS__[
log_level], fmt='%(asctime)s %(levelname)-7s %(message)s')
logging.basicConfig(
level=__LOG_LEVELS__[log_level],
format='%(asctime)s %(levelname)-7s %(message)s',
)

logging.info("Starting to parse ...")
data = CreateParser().parse(open(filename).read(), file_name=filename)
Expand Down
7 changes: 4 additions & 3 deletions scripts/py_matter_idl/matter_idl/xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import pprint

import click
import coloredlogs

# Supported log levels, mapping string values required for argument
# parsing into logging constants
Expand All @@ -59,8 +58,10 @@
help='Do not pring output data (parsed data)')
@ click.argument('filenames', nargs=-1)
def main(log_level, no_print, filenames):
coloredlogs.install(level=__LOG_LEVELS__[
log_level], fmt='%(asctime)s %(levelname)-7s %(message)s')
logging.basicConfig(
level=__LOG_LEVELS__[log_level],
format='%(asctime)s %(levelname)-7s %(message)s',
)

logging.info("Starting to parse ...")

Expand Down

0 comments on commit 7896c23

Please sign in to comment.