proj: Add tid to msg()
This commit is contained in:
@@ -602,7 +602,7 @@ static void msg(const char *fmt, ...) {
|
|||||||
|
|
||||||
struct timespec spec;
|
struct timespec spec;
|
||||||
clock_gettime(CLOCK_REALTIME, &spec);
|
clock_gettime(CLOCK_REALTIME, &spec);
|
||||||
size_t offset = snprintf(buf, sizeof(buf), "%li.%09li %i ", spec.tv_sec, spec.tv_nsec, getpid());
|
size_t offset = snprintf(buf, sizeof(buf), "%li.%09li %i %i ", spec.tv_sec, spec.tv_nsec, getpid(), gettid());
|
||||||
for (char ch, state = 0; (ch = *fmt) != 0 && offset < sizeof(buf); fmt++) {
|
for (char ch, state = 0; (ch = *fmt) != 0 && offset < sizeof(buf); fmt++) {
|
||||||
if (state == '%') {
|
if (state == '%') {
|
||||||
if (ch == '%') {
|
if (ch == '%') {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Handler(StreamRequestHandler):
|
|||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
first = self.rfile.readline()
|
first = self.rfile.readline()
|
||||||
meta = {a[0]: a[1] for a in [tuple(p.decode('utf-8').split(':', 1)) for p in first.split(b' ', 2)[2].strip().split(b';')]}
|
meta = {a[0]: a[1] for a in [tuple(p.decode('utf-8').split(':', 1)) for p in first.split(b' ', 3)[3].strip().split(b';')]}
|
||||||
self.pid = int(meta['PID']) if 'PID' in meta else None
|
self.pid = int(meta['PID']) if 'PID' in meta else None
|
||||||
self.path = meta['PATH'] if 'PATH' in meta else None
|
self.path = meta['PATH'] if 'PATH' in meta else None
|
||||||
self.stack = []
|
self.stack = []
|
||||||
@@ -163,7 +163,7 @@ class Handler(StreamRequestHandler):
|
|||||||
return tuple(args), idx
|
return tuple(args), idx
|
||||||
|
|
||||||
def handle_msg(self, msg: bytes):
|
def handle_msg(self, msg: bytes):
|
||||||
timestamp, pid, data = msg.rstrip(b'\n').split(b' ', 2)
|
timestamp, pid, tid, data = msg.rstrip(b'\n').split(b' ', 3)
|
||||||
if not data.startswith(b'return ') and not data == b'return':
|
if not data.startswith(b'return ') and not data == b'return':
|
||||||
call = data.decode('utf-8')
|
call = data.decode('utf-8')
|
||||||
print(f'[{self.pid}] {call}')
|
print(f'[{self.pid}] {call}')
|
||||||
|
|||||||
Reference in New Issue
Block a user