mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 05:04:38 +03:00
Switch logging config to ini format
Implement #61 Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
10
aqt/cli.py
10
aqt/cli.py
@@ -28,8 +28,6 @@ import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
import yaml
|
||||
|
||||
from aqt.archives import QtArchives, ToolArchives
|
||||
from aqt.installer import QtInstaller
|
||||
|
||||
@@ -141,7 +139,7 @@ class Cli():
|
||||
parser = argparse.ArgumentParser(prog='aqt', description='Installer for Qt SDK.',
|
||||
formatter_class=argparse.RawTextHelpFormatter, add_help=True)
|
||||
parser.add_argument('--logging-conf', type=argparse.FileType('r'),
|
||||
nargs=1, help="Specify logging configuration YAML file.")
|
||||
nargs=1, help="Logging configuration ini file.")
|
||||
parser.add_argument('--logger', nargs=1, help="Specify logger name")
|
||||
parser.add_argument('--dry-run', action='store_true', help='Dry run operations.')
|
||||
subparsers = parser.add_subparsers(title='subcommands', description='Valid subcommands',
|
||||
@@ -198,10 +196,8 @@ class Cli():
|
||||
elif envconf is not None:
|
||||
conf = envconf
|
||||
if conf is None or not os.path.exists(conf):
|
||||
conf = os.path.join(os.path.dirname(__file__), 'logging.yml')
|
||||
with open(conf, 'r') as f:
|
||||
log_config = yaml.safe_load(f.read())
|
||||
logging.config.dictConfig(log_config)
|
||||
conf = os.path.join(os.path.dirname(__file__), 'logging.ini')
|
||||
logging.config.fileConfig(conf)
|
||||
if args.logger is not None:
|
||||
self.logger = logging.getLogger(args.logger)
|
||||
else:
|
||||
|
||||
42
aqt/logging.ini
Normal file
42
aqt/logging.ini
Normal file
@@ -0,0 +1,42 @@
|
||||
[loggers]
|
||||
keys=root,aqt
|
||||
|
||||
[logger_root]
|
||||
level=NOTSET
|
||||
handlers=console
|
||||
|
||||
[logger_aqt]
|
||||
level=INFO
|
||||
handlers=console,file
|
||||
propagate=1
|
||||
qualname=aqt
|
||||
|
||||
[formatters]
|
||||
keys=verbose,simple,brief
|
||||
|
||||
[formatter_verbose]
|
||||
format=%(asctime)s - %(name)s - %(levelname)s - %(module)s %(thread)d %(message)s
|
||||
class=logging.Formatter
|
||||
|
||||
[formatter_simple]
|
||||
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
||||
class=logging.Formatter
|
||||
|
||||
[formatter_brief]
|
||||
format=%(message)s
|
||||
class=logging.Formatter
|
||||
|
||||
[handlers]
|
||||
keys=console,file
|
||||
|
||||
[handler_console]
|
||||
level=WARN
|
||||
class=logging.StreamHandler
|
||||
formatter=brief
|
||||
args=(sys.stdout,)
|
||||
|
||||
[handler_file]
|
||||
level=INFO
|
||||
class=logging.FileHandler
|
||||
formatter=simple
|
||||
args=('aqtinstall.log', 'a')
|
||||
@@ -1,32 +0,0 @@
|
||||
version: 1
|
||||
disable_existing_loggers: False
|
||||
|
||||
formatters:
|
||||
simple:
|
||||
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
brief:
|
||||
format: '%(message)s'
|
||||
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
level: WARN
|
||||
formatter: brief
|
||||
stream: ext://sys.stdout
|
||||
|
||||
file:
|
||||
class: logging.FileHandler
|
||||
level: INFO
|
||||
formatter: simple
|
||||
filename: aqtinstall.log
|
||||
encoding: utf-8
|
||||
|
||||
loggers:
|
||||
aqt:
|
||||
level: ERROR
|
||||
handler: [console]
|
||||
propagate: yes
|
||||
|
||||
root:
|
||||
level: INFO
|
||||
handlers: [console, file]
|
||||
@@ -7,4 +7,3 @@ flake8
|
||||
wheel
|
||||
twine
|
||||
py7zr>=0.4.1 ; python_version > '3.5'
|
||||
pyyaml
|
||||
|
||||
2
setup.py
2
setup.py
@@ -21,7 +21,7 @@ setup(name='aqtinstall',
|
||||
author_email='miurahr@linux.com',
|
||||
packages=["aqt"],
|
||||
package_data={'aqt': ['*.yml', "*.json", "*.ini"]},
|
||||
install_requires=['requests', 'six', 'py7zr', 'pyyaml'],
|
||||
install_requires=['requests', 'six', 'py7zr'],
|
||||
extras_require={'dev': ['pytest', 'pytest-pep8', 'pytest-cov', 'flake8']},
|
||||
scripts=["bin/aqt"],
|
||||
classifiers=[
|
||||
|
||||
@@ -11,7 +11,7 @@ def test_cli_help(capsys):
|
||||
"optional arguments:\n",
|
||||
" -h, --help show this help message and exit\n",
|
||||
" --logging-conf LOGGING_CONF\n",
|
||||
" Specify logging configuration YAML file.\n",
|
||||
" Logging configuration ini file.\n",
|
||||
" --logger LOGGER Specify logger name\n",
|
||||
" --dry-run Dry run operations.\n",
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user