mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Implement Click logging handler for package manager
This commit is contained in:
2
docs
2
docs
Submodule docs updated: e672ed7a4a...fc5cf10724
@ -14,7 +14,6 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
import click
|
||||
@ -41,6 +40,11 @@ from platformio.package.meta import (
|
||||
from platformio.project.helpers import get_project_cache_dir
|
||||
|
||||
|
||||
class ClickLoggingHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
click.echo(self.format(record))
|
||||
|
||||
|
||||
class BasePackageManager( # pylint: disable=too-many-public-methods,too-many-instance-attributes
|
||||
PackageManagerDownloadMixin,
|
||||
PackageManageRegistryMixin,
|
||||
@ -72,7 +76,7 @@ class BasePackageManager( # pylint: disable=too-many-public-methods,too-many-in
|
||||
logger = logging.getLogger(str(self.__class__.__name__).replace("Package", " "))
|
||||
logger.setLevel(logging.INFO)
|
||||
formatter = logging.Formatter("%(name)s: %(message)s")
|
||||
sh = logging.StreamHandler(sys.stdout)
|
||||
sh = ClickLoggingHandler()
|
||||
sh.setFormatter(formatter)
|
||||
logger.handlers.clear()
|
||||
logger.addHandler(sh)
|
||||
|
Reference in New Issue
Block a user