laverdet / node-fibers

Fiber/coroutine support for v8 and node.
MIT License
3.56k stars 224 forks source link

Create flags to enable logs when call methods with fibers is in use. #461

Closed denihs closed 2 years ago

denihs commented 2 years ago

To enable logs using environment variable with params:

ENABLE_LOG_USE_FIBERS=1 to log calls with fibers. ENABLE_LOG_USE_FIBERS=2 to log calls with fibers and print stack trace.

Usages example:

#!/usr/bin/env bash
echo ">>>>>> NO Log"
node log-fibers-test.js && echo ok
ENABLE_LOG_USE_FIBERS=0 node log-fibers-test.js && echo ok
echo ">>>>>> Log level 1"
ENABLE_LOG_USE_FIBERS=1 node log-fibers-test.js
echo ">>>>>> Log level 2 no filters"
ENABLE_LOG_USE_FIBERS=2 node log-fibers-test.js
echo ">>>>>> Log level 2 with filters matches"
ENABLE_LOG_USE_FIBERS=2 LOG_USE_FIBERS_INCLUDE_IN_PATH=meteor-fibers/node-fibers node log-fibers-test.js
echo ">>>>>> Log level 2 with filters no matches"
ENABLE_LOG_USE_FIBERS=2 LOG_USE_FIBERS_INCLUDE_IN_PATH=meteor-fibers/node2-fibers node log-fibers-test.js

To save all output messages in a file using shell redirect

ENABLE_LOG_USE_FIBERS=2 meteor &> fibers-stack.log