Skip to content

Commit

Permalink
Reduce log spam in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zwimer committed Oct 14, 2024
1 parent 5ad6792 commit 55f14f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rpipe/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: str = "9.0.5" # Must be "<major>.<minor>.<patch>", all numbers
__version__: str = "9.0.6" # Must be "<major>.<minor>.<patch>", all numbers
8 changes: 5 additions & 3 deletions rpipe/server/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from logging import StreamHandler, FileHandler, Formatter, getLevelName, getLogger, shutdown
from logging import DEBUG, INFO, StreamHandler, FileHandler, Formatter, getLevelName, getLogger, shutdown
from os import environ, close as fd_close
from dataclasses import dataclass
from tempfile import mkstemp
Expand Down Expand Up @@ -29,10 +29,12 @@ def _logged(func):
@wraps(func)
def wrapper(*args, **kwargs):
ret = func(*args, **kwargs)
if not server.debug: # Flask already does what we want
if not server.debug: # Flask in debug mode already does what we want
if (fp := request.full_path).endswith("?"):
fp = fp[:-1]
getLogger(_LOG).info('%s - "%s %s" %d', request.remote_addr, request.method, fp, ret.status_code)
lvl = DEBUG if (ret.status_code < 300 or ret.status_code == 425) else INFO
args = (request.remote_addr, request.method, fp, ret.status_code)
getLogger(_LOG).log(lvl, '%s - "%s %s" %d', *args)
return ret

return wrapper
Expand Down
12 changes: 6 additions & 6 deletions rpipe/server/channel/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from flask import request

from ...shared import QueryEC
from ...shared import TRACE, QueryEC
from ..util import plaintext, json_response
from ..server import ServerShutdown
from .write import write
Expand Down Expand Up @@ -41,17 +41,17 @@ def _handler(state: State, channel: str) -> Response:

def handler(state: State, channel: str) -> Response:
log = getLogger("channel")
log.info("Invoking: %s %s", request.method, channel)
log.debug("Invoking: %s %s", request.method, channel)
ret = _handler(state, channel)
log.info("Sending: %s", ret)
if ret.status_code >= 400:
log.debug(" body: %s", ret.get_data())
if ret.status_code >= 300:
log.debug("Sending: %s", ret)
log.log(TRACE, "Body: %s", ret.get_data())
return ret


def query(state: State, channel: str) -> Response:
log = getLogger("query")
log.info("Query %s", channel)
log.debug("Query %s", channel)
with state as u:
if (s := u.streams.get(channel, None)) is None:
log.debug("Channel not found: %s", channel)
Expand Down

0 comments on commit 55f14f2

Please sign in to comment.