diff --git a/niimprint/__main__.py b/niimprint/__main__.py index 4cdaae0..e8500a6 100644 --- a/niimprint/__main__.py +++ b/niimprint/__main__.py @@ -1,3 +1,4 @@ +import logging import re import click @@ -51,7 +52,18 @@ from niimprint import BluetoothTransport, PrinterClient, SerialTransport required=True, help="Image path", ) -def print_cmd(model, conn, addr, density, rotate, image): +@click.option( + "-v", + "--verbose", + is_flag=True, + help="Enable verbose logging", +) +def print_cmd(model, conn, addr, density, rotate, image, verbose): + logging.basicConfig( + level="DEBUG" if verbose else "INFO", + format="%(levelname)s | %(module)s:%(funcName)s:%(lineno)d - %(message)s", + ) + if conn == "bluetooth": assert conn is not None, "--addr argument required for bluetooth connection" addr = addr.upper() diff --git a/niimprint/printer.py b/niimprint/printer.py index 5f6caef..887d576 100644 --- a/niimprint/printer.py +++ b/niimprint/printer.py @@ -82,7 +82,7 @@ class SerialTransport(BaseTransport): if len(all_ports) == 0: raise RuntimeError("No serial ports detected") if len(all_ports) > 1: - msg = "Too many serial ports, please select one via SERIAL_PORT env var:" + msg = "Too many serial ports, please select specific one:" for port, desc, hwid in all_ports: msg += f"\n- {port} : {desc} [{hwid}]" raise RuntimeError(msg) diff --git a/readme.md b/readme.md index 74824ee..010e4fb 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,7 @@ Options: -d, --density INTEGER RANGE Print density [default: 5; 1<=x<=5] -r, --rotate [0|90|180|270] Image rotation (clockwise) [default: 0] -i, --image PATH Image path [required] + -v, --verbose Enable verbose logging --help Show this message and exit. ```