mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
review loggers
This commit is contained in:
parent
03c298c762
commit
18daecaac7
@ -1,5 +1,5 @@
|
||||
[loggers]
|
||||
keys = root,build_details,database,http,stderr,boto3,botocore,nose,s3transfer
|
||||
keys = root,build,http,stderr,boto3,botocore,nose,s3transfer
|
||||
|
||||
[handlers]
|
||||
keys = console_handler,syslog_handler
|
||||
@ -32,16 +32,10 @@ level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = root
|
||||
|
||||
[logger_build_details]
|
||||
[logger_build]
|
||||
level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = build_details
|
||||
propagate = 0
|
||||
|
||||
[logger_database]
|
||||
level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = database
|
||||
qualname = build
|
||||
propagate = 0
|
||||
|
||||
[logger_http]
|
||||
|
@ -51,7 +51,7 @@ class Remote:
|
||||
"""
|
||||
default constructor
|
||||
"""
|
||||
self.logger = logging.getLogger("build_details")
|
||||
self.logger = logging.getLogger("build")
|
||||
|
||||
@classmethod
|
||||
def info(cls: Type[Remote], package_name: str, *, pacman: Pacman) -> AURPackage:
|
||||
|
@ -50,7 +50,7 @@ class Repo:
|
||||
paths(RepositoryPaths): repository paths instance
|
||||
sign_args(List[str]): additional args which have to be used to sign repository archive
|
||||
"""
|
||||
self.logger = logging.getLogger("build_details")
|
||||
self.logger = logging.getLogger("build")
|
||||
self.name = name
|
||||
self.paths = paths
|
||||
self.uid, _ = paths.root_owner
|
||||
|
@ -40,7 +40,7 @@ class Sources:
|
||||
"""
|
||||
|
||||
DEFAULT_BRANCH = "master" # default fallback branch
|
||||
logger = logging.getLogger("build_details")
|
||||
logger = logging.getLogger("build")
|
||||
|
||||
_check_output = check_output
|
||||
|
||||
|
@ -36,7 +36,6 @@ class Task:
|
||||
base package build task
|
||||
|
||||
Attributes:
|
||||
build_logger(logging.Logger): logger for build process
|
||||
logger(logging.Logger): class logger
|
||||
package(Package): package definitions
|
||||
paths(RepositoryPaths): repository paths instance
|
||||
@ -54,8 +53,7 @@ class Task:
|
||||
configuration(Configuration): configuration instance
|
||||
paths(RepositoryPaths): repository paths instance
|
||||
"""
|
||||
self.logger = logging.getLogger("root")
|
||||
self.build_logger = logging.getLogger("build_details")
|
||||
self.logger = logging.getLogger("build")
|
||||
self.package = package
|
||||
self.paths = paths
|
||||
self.uid, _ = paths.root_owner
|
||||
@ -85,14 +83,14 @@ class Task:
|
||||
*command,
|
||||
exception=BuildFailed(self.package.base),
|
||||
cwd=sources_dir,
|
||||
logger=self.build_logger,
|
||||
logger=self.logger,
|
||||
user=self.uid)
|
||||
|
||||
# well it is not actually correct, but we can deal with it
|
||||
packages = Task._check_output("makepkg", "--packagelist",
|
||||
exception=BuildFailed(self.package.base),
|
||||
cwd=sources_dir,
|
||||
logger=self.build_logger).splitlines()
|
||||
logger=self.logger).splitlines()
|
||||
return [Path(package) for package in packages]
|
||||
|
||||
def init(self, sources_dir: Path, database: SQLite) -> None:
|
||||
|
@ -54,7 +54,7 @@ class Migrations:
|
||||
"""
|
||||
self.connection = connection
|
||||
self.configuration = configuration
|
||||
self.logger = logging.getLogger("database")
|
||||
self.logger = logging.getLogger("root")
|
||||
|
||||
@classmethod
|
||||
def migrate(cls: Type[Migrations], connection: Connection, configuration: Configuration) -> MigrationResult:
|
||||
|
@ -45,7 +45,7 @@ class Operations:
|
||||
path(Path): path to the database file
|
||||
"""
|
||||
self.path = path
|
||||
self.logger = logging.getLogger("database")
|
||||
self.logger = logging.getLogger("root")
|
||||
|
||||
@staticmethod
|
||||
def factory(cursor: Cursor, row: Tuple[Any, ...]) -> Dict[str, Any]:
|
||||
|
@ -51,7 +51,7 @@ class GPG:
|
||||
architecture(str): repository architecture
|
||||
configuration(Configuration): configuration instance
|
||||
"""
|
||||
self.logger = logging.getLogger("build_details")
|
||||
self.logger = logging.getLogger("build")
|
||||
self.architecture = architecture
|
||||
self.configuration = configuration
|
||||
self.targets, self.default_key = self.sign_options(configuration)
|
||||
|
@ -281,7 +281,7 @@ class Package:
|
||||
|
||||
from ahriman.core.build_tools.sources import Sources
|
||||
|
||||
logger = logging.getLogger("build_details")
|
||||
logger = logging.getLogger("build")
|
||||
Sources.load(paths.cache_for(self.base), self, None, paths)
|
||||
|
||||
try:
|
||||
|
@ -267,7 +267,7 @@ def test_load_logging_fallback(configuration: Configuration, mocker: MockerFixtu
|
||||
"""
|
||||
must fallback to stderr without errors
|
||||
"""
|
||||
mocker.patch("logging.config.fileConfig", side_effect=PermissionError())
|
||||
mocker.patch("ahriman.core.configuration.fileConfig", side_effect=PermissionError())
|
||||
configuration.load_logging(quiet=False)
|
||||
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
[loggers]
|
||||
keys = root,builder,build_details,http
|
||||
|
||||
[handlers]
|
||||
keys = console_handler,build_file_handler,file_handler,http_handler,syslog_handler
|
||||
|
||||
[formatters]
|
||||
keys = generic_format,syslog_format
|
||||
|
||||
[handler_console_handler]
|
||||
class = StreamHandler
|
||||
level = DEBUG
|
||||
formatter = generic_format
|
||||
args = (sys.stderr,)
|
||||
|
||||
[handler_file_handler]
|
||||
class = logging.handlers.RotatingFileHandler
|
||||
level = DEBUG
|
||||
formatter = generic_format
|
||||
args = ("/var/log/ahriman/ahriman.log", "a", 20971520, 20)
|
||||
|
||||
[handler_build_file_handler]
|
||||
class = logging.handlers.RotatingFileHandler
|
||||
level = DEBUG
|
||||
formatter = generic_format
|
||||
args = ("/var/log/ahriman/build.log", "a", 20971520, 20)
|
||||
|
||||
[handler_http_handler]
|
||||
class = logging.handlers.RotatingFileHandler
|
||||
level = DEBUG
|
||||
formatter = generic_format
|
||||
args = ("/var/log/ahriman/http.log", "a", 20971520, 20)
|
||||
|
||||
[handler_syslog_handler]
|
||||
class = logging.handlers.SysLogFileHandler
|
||||
level = DEBUG
|
||||
formatter = syslog_format
|
||||
args = ("/dev/log",)
|
||||
|
||||
[formatter_generic_format]
|
||||
format = [%(levelname)s %(asctime)s] [%(filename)s:%(lineno)d] [%(funcName)s]: %(message)s
|
||||
datefmt =
|
||||
|
||||
[formatter_syslog_format]
|
||||
format = [%(levelname)s] [%(filename)s:%(lineno)d] [%(funcName)s]: %(message)s
|
||||
datefmt =
|
||||
|
||||
[logger_root]
|
||||
level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = root
|
||||
|
||||
[logger_builder]
|
||||
level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = builder
|
||||
propagate = 0
|
||||
|
||||
[logger_build_details]
|
||||
level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = build_details
|
||||
propagate = 0
|
||||
|
||||
[logger_http]
|
||||
level = DEBUG
|
||||
handlers = syslog_handler
|
||||
qualname = http
|
||||
propagate = 0
|
1
tests/testresources/core/logging.ini
Symbolic link
1
tests/testresources/core/logging.ini
Symbolic link
@ -0,0 +1 @@
|
||||
../../../package/share/ahriman/settings/ahriman.ini.d/logging.ini
|
Loading…
Reference in New Issue
Block a user