| 168 | |
| 169 | #define FMT_MAX 256 |
| 170 | static void |
| 171 | set_format_string(int method, const char *daemon) |
| 172 | { |
| 173 | int offset = 0; |
| 174 | char fmt[FMT_MAX]; |
| 175 | |
| 176 | if (method > QB_LOG_STDERR) { |
| 177 | /* When logging to a file */ |
| 178 | struct utsname res; |
| 179 | |
| 180 | if (uname(&res) == 0) { |
| 181 | offset += |
| 182 | snprintf(fmt + offset, FMT_MAX - offset, "%%t [%d] %s %10s: ", getpid(), |
| 183 | res.nodename, daemon); |
| 184 | } else { |
| 185 | offset += snprintf(fmt + offset, FMT_MAX - offset, "%%t [%d] %10s: ", getpid(), daemon); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | if (crm_tracing_enabled() && method >= QB_LOG_STDERR) { |
| 190 | offset += snprintf(fmt + offset, FMT_MAX - offset, "(%%-12f:%%5l %%g) %%-7p: %%n: "); |
| 191 | } else { |
| 192 | offset += snprintf(fmt + offset, FMT_MAX - offset, "%%g %%-7p: %%n: "); |
| 193 | } |
| 194 | |
| 195 | if (method == QB_LOG_SYSLOG) { |
| 196 | offset += snprintf(fmt + offset, FMT_MAX - offset, "%%b"); |
| 197 | } else { |
| 198 | offset += snprintf(fmt + offset, FMT_MAX - offset, "\t%%b"); |
| 199 | } |
| 200 | qb_log_format_set(method, fmt); |
| 201 | } |
| 202 | |
| 203 | gboolean |
| 204 | crm_add_logfile(const char *filename) |
no test coverage detected