Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Prefix all messages with application name #14

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+8 −1
Split
View
9 msg.c
@@ -40,11 +40,14 @@
void vfmsg(FILE *f,
const char *pre, const char *suf, const char *fmt,
va_list ap) {
- int prelen = 0, fmtlen = 0, suflen = 0;
+ int prelen = 0, fmtlen = 0, suflen = 0, proglen = 0;
+ char prog[30] = "[reattach-to-user-namespace] ";
+ proglen = strlen(prog);
if (pre) prelen = strlen(pre);
if (fmt) fmtlen = strlen(fmt);
if (suf) suflen = strlen(suf);
char *newfmt = malloc(
+ proglen*2 +
prelen*2 + /* %-doubled pre */
fmtlen +
2 + /* ':' and SP */
@@ -55,6 +58,10 @@ void vfmsg(FILE *f,
goto finish;
char *newfmt_end = newfmt;
+ if(proglen) {
+ strcpy(newfmt_end, prog);
+ newfmt_end += proglen;
+ }
if (prelen)
while(*pre)
if ((*newfmt_end++ = *pre++) == '%')