logit(): avoid extra \n when logging to stderr

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2022-03-23 06:33:21 +01:00
parent ae09272bcc
commit 685f332c6e
2 changed files with 6 additions and 4 deletions
+2
View File
@@ -116,6 +116,7 @@ void logit(int prio, const char *fmt, ...)
if (in_container() || !(fp = fopen("/dev/kmsg", "w"))) {
vfprintf(stderr, fmt, ap);
fputs("\n", stderr);
goto done;
}
@@ -127,6 +128,7 @@ void logit(int prio, const char *fmt, ...)
va_end(ap);
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
fputs("\n", stderr);
}
done:
+4 -4
View File
@@ -40,10 +40,10 @@
* The default log level is LOG_NOTICE. To toggle LOG_DEBUG messages,
* use `initctl debug` or add `debug` to the kernel cmdline.
*/
#define _d(fmt, args...) logit(LOG_DEBUG, "%s():" fmt "\n", __func__, ##args)
#define _w(fmt, args...) logit(LOG_WARNING, "%s():" fmt "\n", __func__, ##args)
#define _e(fmt, args...) logit(LOG_ERR, "%s():" fmt "\n", __func__, ##args)
#define _pe(fmt, args...) logit(LOG_ERR, "%s():" fmt ": %s\n", __func__, ##args, strerror(errno))
#define _d(fmt, args...) logit(LOG_DEBUG, "%s():" fmt, __func__, ##args)
#define _w(fmt, args...) logit(LOG_WARNING, "%s():" fmt, __func__, ##args)
#define _e(fmt, args...) logit(LOG_ERR, "%s():" fmt, __func__, ##args)
#define _pe(fmt, args...) logit(LOG_ERR, "%s():" fmt ": %n", __func__, ##args, strerror(errno))
void log_init (void);
void log_exit (void);