Skip to content

Commit

Permalink
[core] Added log topic 'thread'
Browse files Browse the repository at this point in the history
  • Loading branch information
pajama-coder committed May 14, 2024
1 parent 7a65bb5 commit d677d9e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
31 changes: 16 additions & 15 deletions src/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ class Log {
enum Topic {
NO_TOPIC = 0,
ALLOC = 1<<0,
PIPELINE = 1<<1,
DUMP = 1<<2,
LISTENER = 1<<3,
INBOUND = 1<<4,
OUTBOUND = 1<<5,
SOCKET = 1<<6,
FILES = 1<<7,
SUBPROC = 1<<8,
NETLINK = 1<<9,
TCP = 1<<10,
UDP = 1<<11,
HTTP2 = 1<<12,
ELF = 1<<13,
BPF = 1<<14,
USER = 1<<15,
THREAD = 1<<1,
PIPELINE = 1<<2,
DUMP = 1<<3,
LISTENER = 1<<4,
INBOUND = 1<<5,
OUTBOUND = 1<<6,
SOCKET = 1<<7,
FILES = 1<<8,
SUBPROC = 1<<9,
NETLINK = 1<<10,
TCP = 1<<11,
UDP = 1<<12,
HTTP2 = 1<<13,
ELF = 1<<14,
BPF = 1<<15,
USER = 1<<16,
};

static void init();
Expand Down
1 change: 1 addition & 0 deletions src/main-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static const struct {
const char *name;
} s_topic_names[] = {
{ Log::ALLOC , "alloc" },
{ Log::THREAD , "thread" },
{ Log::PIPELINE , "pipeline" },
{ Log::DUMP , "dump" },
{ Log::LISTENER , "listener" },
Expand Down
8 changes: 4 additions & 4 deletions src/worker-thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void WorkerThread::main() {
}

if (started && !failed) {
Log::info("[worker] Thread %d started", m_index);
Log::debug(Log::THREAD, "[thread] Thread %d started", m_index);

init_metrics();

Expand All @@ -495,7 +495,7 @@ void WorkerThread::main() {
m_done = true;
m_manager->on_thread_done(m_index);

Log::info("[worker] Thread %d done", m_index);
Log::debug(Log::THREAD, "[thread] Thread %d done", m_index);

if (m_shutdown) break;

Expand All @@ -511,11 +511,11 @@ void WorkerThread::main() {
if (m_working) {
m_done = false;
Net::current().restart();
Log::info("[worker] Thread %d restarted", m_index);
Log::debug(Log::THREAD, "[thread] Thread %d restarted", m_index);
}
}

Log::info("[worker] Thread %d ended", m_index);
Log::debug(Log::THREAD, "[thread] Thread %d ended", m_index);

} else {
m_new_worker->stop(true);
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function startBaseline() {

function startPipy(args, env) {
return startProcess(
join(binPath, pipyExe), args, env,
join(binPath, pipyExe), ['--log-level=debug:thread', ...args], env,
'pipy', 'Thread 0 started',
);
}
Expand Down
2 changes: 1 addition & 1 deletion test/curl/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function test(name) {
async function startPipy(filename) {
log('Starting Pipy...');
log(pipyBinPath, filename);
const proc = spawn(pipyBinPath, [filename]);
const proc = spawn(pipyBinPath, [filename, '--log-level=debug:thread']);
const lineBuffer = [];
let started = false;
return await Promise.race([
Expand Down
2 changes: 1 addition & 1 deletion test/mux/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async function startCodebase(url, opt) {
new Promise(
resolve => {
const proc = startProcess(
pipyBinPath, ['--no-graph', url, ...(opt?.options || [])],
pipyBinPath, ['--no-graph', '--log-level=debug:thread', url, ...(opt?.options || [])],
line => {
if (!opt?.silent || !started) {
log(chalk.bgGreen('worker >>>'), line);
Expand Down
2 changes: 1 addition & 1 deletion test/stress/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function startCodebase(url, opt) {
resolve => {
let started = false;
const proc = startProcess(
pipyBinPath, ['--no-graph', url, ...(opt?.options || [])],
pipyBinPath, ['--no-graph', '--log-level=debug:thread', url, ...(opt?.options || [])],
line => {
if (!opt?.silent || !started) {
log(chalk.bgGreen('worker >>>'), line);
Expand Down

0 comments on commit d677d9e

Please sign in to comment.