~ubuntu-dev/ubuntu/lucid/mpd/lucid-201002101903

« back to all changes in this revision

Viewing changes to src/log.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-01-28 22:52:37 UTC
  • mfrom: (1.1.10 upstream) (2.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20090128225237-iy51r0n32rr38ojd
Tags: 0.14.1-1ubuntu1
* Merge from debian unstable (LP: #322513), Ubuntu remaining changes:
  - debian/control:
    + Move avahi-daemon from Suggests field to Recommends field.
  - debian/mpd.init.d:
    + Read mpd user from mpd.conf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        return buf;
67
67
}
68
68
 
 
69
/**
 
70
 * Determines the length of the string excluding trailing whitespace
 
71
 * characters.
 
72
 */
 
73
static int
 
74
chomp_length(const char *p)
 
75
{
 
76
        size_t length = strlen(p);
 
77
 
 
78
        while (length > 0 && g_ascii_isspace(p[length - 1]))
 
79
                --length;
 
80
 
 
81
        return (int)length;
 
82
}
 
83
 
69
84
static void
70
85
mpd_log_func(const gchar *log_domain,
71
86
             G_GNUC_UNUSED GLogLevelFlags log_level,
90
105
        if (log_domain == NULL)
91
106
                log_domain = "";
92
107
 
93
 
        fprintf(file, "%s%s%s%s",
 
108
        fprintf(file, "%s%s%s%.*s\n",
94
109
                stdout_mode ? "" : log_date(),
95
110
                log_domain, *log_domain == 0 ? "" : ": ",
96
 
                message);
 
111
                chomp_length(message), message);
97
112
 
98
113
        g_free(converted);
99
114
}