mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 18:41:54 +08:00
pretty logging
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
import contextlib
|
||||
import logging
|
||||
|
||||
from typing import Generator
|
||||
|
||||
from RPi import GPIO
|
||||
|
||||
from .logging import get_logger
|
||||
|
||||
|
||||
# =====
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def bcm() -> Generator[None, None, None]:
|
||||
logger = get_logger(2)
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
_logger.info("Configured GPIO mode as BCM")
|
||||
logger.info("Configured GPIO mode as BCM")
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
GPIO.cleanup()
|
||||
_logger.info("GPIO cleaned")
|
||||
logger.info("GPIO cleaned")
|
||||
|
||||
|
||||
def set_output(pin: int, initial: bool=False) -> int:
|
||||
|
||||
Reference in New Issue
Block a user