Logging¶
Vayu exposes a single named logger, L = logging.getLogger("vayu"), with a NullHandler already attached. Importing the library does not mutate the root logger or the global logging config, so pulling vayulib into a larger app won't duplicate log lines or override your formatters.
Shorthand methods¶
For quick scripts and REPL use:
from vayu import L
L.i("info") # L.info
L.d("debug") # L.debug
L.e("error") # L.error
L.w("warn") # L.warning
L.c("critical") # L.critical
Memory-annotated logs¶
L.mem("msg") appends an RSS snapshot to the message — handy for long-running jobs:
By default it reads /proc/<pid>/statm (Linux). If that file isn't available (e.g. macOS), it falls back to psutil.Process().memory_info().rss — install psutil yourself if you need the fallback.
configure_logging() — opt-in¶
For parity with the previous stdout-with-timezone behavior:
What it does:
- Removes any non-
NullHandleralready on thevayulogger. - Attaches a
StreamHandlerpointed atsys.stdout(override viastream=). - Uses a formatter that renders timestamps in the given IANA timezone (ISO-8601, seconds precision).
- Sets
L.propagate = Falseso the lines don't also go to the root logger. - Quiets
asynciotoWARNING.
Defaults:
level—$LOG_LEVELor"INFO".tz—$TZor"UTC".
Configuring yourself¶
If your app already has a logging setup, skip configure_logging() entirely and configure the "vayu" logger like any other:
import logging
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(name)s %(levelname)s %(message)s"))
vayu_logger = logging.getLogger("vayu")
vayu_logger.addHandler(handler)
vayu_logger.setLevel(logging.INFO)