contain.o: contain.h nsjail.h logs.h caps.h cgroup.h cpu.h mnt.h net.h pid.h
contain.o: user.h uts.h
cpu.o: cpu.h nsjail.h logs.h util.h
-logs.o: logs.h nsjail.h
+logs.o: logs.h util.h nsjail.h
mnt.o: mnt.h nsjail.h logs.h macros.h subproc.h util.h
net.o: net.h nsjail.h logs.h subproc.h
nsjail.o: nsjail.h logs.h cmdline.h macros.h net.h sandbox.h subproc.h util.h
#include <time.h>
#include <unistd.h>
-#include "nsjail.h"
+#include "util.h"
#include <string.h>
{"HB", "\033[1m", false, false},
};
- time_t ltstamp = time(NULL);
- struct tm utctime;
- localtime_r(<stamp, &utctime);
- char timestr[32];
- if (strftime(timestr, sizeof(timestr) - 1, "%FT%T%z", &utctime) == 0) {
- timestr[0] = '\0';
- }
-
/* Start printing logs */
if (_log_fd_isatty) {
dprintf(_log_fd, "%s", logLevels[ll].prefix);
}
if (logLevels[ll].print_time) {
- dprintf(_log_fd, "[%s] ", timestr);
+ const auto timestr = util::timeToStr(time(NULL));
+ dprintf(_log_fd, "[%s] ", timestr.c_str());
}
if (logLevels[ll].print_funcline) {
dprintf(_log_fd, "[%s][%d] %s():%d ", logLevels[ll].descr, (int)getpid(), fn, ln);