Rebrand the Rust client crate (coven/ → hh/, package+binary "hack-house"), README, CLI strings, and branch (coven → hack-house). Gitea repo renamed cmd-chat → hack-house to match. Crypto/server logic unchanged; selftest + golden-vector test still green, binary is now `hack-house`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
import logging
|
|
import os
|
|
|
|
from sanic.helpers import Default, _default
|
|
from sanic.log import (
|
|
access_logger,
|
|
error_logger,
|
|
logger,
|
|
server_logger,
|
|
websockets_logger,
|
|
)
|
|
from sanic.logging.formatter import (
|
|
AutoAccessFormatter,
|
|
AutoFormatter,
|
|
DebugAccessFormatter,
|
|
DebugFormatter,
|
|
ProdAccessFormatter,
|
|
ProdFormatter,
|
|
)
|
|
|
|
|
|
def setup_logging(
|
|
debug: bool,
|
|
no_color: bool = False,
|
|
log_extra: bool | Default = _default,
|
|
) -> None:
|
|
if AutoFormatter.SETUP:
|
|
return
|
|
|
|
if isinstance(log_extra, Default):
|
|
log_extra = debug
|
|
os.environ["SANIC_LOG_EXTRA"] = str(log_extra)
|
|
AutoFormatter.LOG_EXTRA = log_extra
|
|
|
|
if no_color:
|
|
os.environ["SANIC_NO_COLOR"] = str(no_color)
|
|
AutoFormatter.NO_COLOR = no_color
|
|
|
|
AutoFormatter.SETUP = True
|
|
|
|
for lggr in (logger, server_logger, error_logger, websockets_logger):
|
|
_auto_format(
|
|
lggr,
|
|
AutoFormatter,
|
|
DebugFormatter if debug else ProdFormatter,
|
|
)
|
|
_auto_format(
|
|
access_logger,
|
|
AutoAccessFormatter,
|
|
DebugAccessFormatter if debug else ProdAccessFormatter,
|
|
)
|
|
|
|
|
|
def _auto_format(
|
|
logger: logging.Logger,
|
|
auto_class: type[AutoFormatter],
|
|
formatter_class: type[AutoFormatter],
|
|
) -> None:
|
|
for handler in logger.handlers:
|
|
if type(handler.formatter) is auto_class:
|
|
handler.setFormatter(formatter_class())
|