Use kernel log-level 6 by default

This commit is contained in:
Michal Moskal 2017-07-27 12:49:19 +01:00
parent 14783eadc2
commit 8f9b9a5e4e
2 changed files with 13 additions and 6 deletions

View File

@ -29,23 +29,30 @@ uint64_t ntohll(uint64_t a) {
void mylog(const char *fmt, ...) {
va_list args;
char *p;
char *p, *p2;
va_start(args, fmt);
vasprintf(&p, fmt, args);
vprintf(fmt, args);
va_end(args);
int len = strlen(p) + 1;
p[len - 1] = '\n';
if (p[0] != '<')
asprintf(&p2, "<6>%s\n", p);
else
asprintf(&p2, "%s\n", p);
int len = strlen(p2);
#ifdef X86
write(2, p, len);
write(2, p2, len);
#else
int fd = open("/dev/kmsg", O_WRONLY);
write(fd, p, len);
write(fd, p2, len);
close(fd);
#endif
free(p);
free(p2);
}
void readAll(int fd, void *dst, uint32_t length) {

View File

@ -37,7 +37,7 @@ void mylog(const char *fmt, ...);
#define FAIL(args...) \
do { \
mylog(args); \
mylog("<4>" args); \
exit(1); \
} while (0)