diff --git a/metricq/cli/__init__.py b/metricq/cli/__init__.py index e052c0e6..2fdc524b 100644 --- a/metricq/cli/__init__.py +++ b/metricq/cli/__init__.py @@ -10,7 +10,6 @@ metricq_command, metricq_metric_option, metricq_server_option, - metricq_syslog, metricq_token_option, ) @@ -24,6 +23,5 @@ "metricq_command", "metricq_metric_option", "metricq_server_option", - "metricq_syslog", "metricq_token_option", ] diff --git a/metricq/cli/wrapper.py b/metricq/cli/wrapper.py index 1f28d2ae..01fa1367 100644 --- a/metricq/cli/wrapper.py +++ b/metricq/cli/wrapper.py @@ -74,7 +74,7 @@ def get_metric_command_logger() -> logging.Logger: return logger -def metricq_command( +def __metricq_command( default_token: str, client_version: str | None = None ) -> Callable[[FC], click.Command]: logger = get_metric_command_logger() @@ -124,13 +124,12 @@ def format(self, record: logging.LogRecord) -> str: # Format the header as " TIMESTAMP HOSTNAME PROGRAM[PID]: MESSAGE" # is already beeing set by the SysLogHanlder, we only need to add the rest syslog_header = f"{timestamp} {hostname} {program}[{pid}]: " - message = super().format(record) return syslog_header + message -def metricq_syslog( - required: bool = True, default: Optional[str] = None +def metricq_command( + *args, required: bool = False, default: Optional[str] = None, **kwargs ) -> Callable[[FC], FC]: def get_syslog_handler(address: str) -> SysLogHandler: if ":" in address: @@ -139,7 +138,8 @@ def get_syslog_handler(address: str) -> SysLogHandler: else: return SysLogHandler(address=address) - def decorator(func): # type: ignore + def decorator(func):# type: ignore + @__metricq_command(*args, **kwargs) @click.option( "--syslog", default=default,