Initial Commit
This commit is contained in:
commit
4dbdc7d793
18 changed files with 2384 additions and 0 deletions
32
pyqt6_scaffold/core/logging.py
Normal file
32
pyqt6_scaffold/core/logging.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import logging
|
||||
|
||||
def setup_logger(name: str = "scaffold"):
|
||||
"""
|
||||
Create and configure a logger with console output.
|
||||
|
||||
Returns an existing logger if one with the given name
|
||||
already exists to avoid duplicate handlers.
|
||||
|
||||
Args:
|
||||
name: Logger name, typically __name__.
|
||||
|
||||
Returns:
|
||||
Configured logging.Logger instance.
|
||||
"""
|
||||
logger = logging.getLogger(name)
|
||||
|
||||
if logger.handlers:
|
||||
return logger
|
||||
|
||||
formatter = logging.Formatter(
|
||||
fmt="[%(asctime)s] %(levelname)-8s %(name)s: %(message)s",
|
||||
datefmt="%H:%M:%S"
|
||||
)
|
||||
|
||||
console = logging.StreamHandler()
|
||||
console.setFormatter(formatter)
|
||||
|
||||
logger.addHandler(console)
|
||||
return logger
|
||||
Loading…
Add table
Add a link
Reference in a new issue