Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Prefix all messages with application name #14

Closed
wants to merge 1 commit into from

2 participants

Simon Gate Chris Johnsen
Simon Gate

When I updated to 10.7 I started getting a error message in my terminal. Didn't know where it came from but I had my suspicions. I think it would be nice to prefix all error messages with the application name to make it obvious where the message came from.

I'm no C programmer but I have attached a patch.

Chris Johnsen
Owner

I shied away from doing something like this originally since it seemed like it would be a bit obnoxious when the user probably just typed the command (e.g. reattach-to-user-namespace pbpaste). However, the common configuration (as described in the README, even) uses the command in an automatic fashion (in tmux default-command), so the user is less likely to be aware of the entire context (such a configuration is likely “set and forget”).

So, given the typical usage, it is a good idea to incorporate the program name to give the user a hint about the source of the message.

I would rather make the change in the “wrapper” instead of the generic msg.c utility code, though. I will put together a different change and push it out soon.

Thanks!

Chris Johnsen
Owner

I just pushed a few commits to the pu branch that culminate in adding the wrapper’s name to several of its messages. The current tip of pu (3c1756e) is the commit that modifies the messages (though it builds on several earlier pu commits, so the surrounding code is a bit different from what is in master).

If you want to try it out, you could (temporarily) add a line like

os=1090;

right before the release number tests (e.g. before line 114).

Simon Gate

Works like a charm! Thank you very much. Also, i'm closing this PL.

Simon Gate smgt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 1, 2012
  1. Simon Gate
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 msg.c
9 msg.c
View
@@ -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++) == '%')
Something went wrong with that request. Please try again.