~ubuntu-branches/ubuntu/saucy/ucarp/saucy

« back to all changes in this revision

Viewing changes to src/log.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Evans
  • Date: 2004-12-24 12:39:30 UTC
  • Revision ID: james.westby@ubuntu.com-20041224123930-9qnzcd6o5j0jjjvm
Tags: 1.1-2
Patched to correct a bug that caused upscript to also be applied
when state changed to BACKUP, if --dowscript was passed before
--upscript, (Closes: #284891). Thanks Michail Bachmann
<michail.bachmann@cms.hu-berlin.de>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <config.h>
 
2
#include "ucarp.h"
 
3
 
 
4
#ifdef WITH_DMALLOC
 
5
# include <dmalloc.h>
 
6
#endif
 
7
 
 
8
void logfile(const int crit, const char *format, ...)
 
9
{
 
10
    const char *urgency;    
 
11
    va_list va;
 
12
    char line[MAX_SYSLOG_LINE];
 
13
    
 
14
    va_start(va, format);
 
15
    vsnprintf(line, sizeof line, format, va);
 
16
    switch (crit) {
 
17
    case LOG_INFO:
 
18
        urgency = "[INFO] ";
 
19
        break;
 
20
    case LOG_WARNING:
 
21
        urgency = "[WARNING] ";
 
22
        break;
 
23
    case LOG_ERR:
 
24
        urgency = "[ERROR] ";
 
25
        break;
 
26
    case LOG_NOTICE:
 
27
        urgency = "[NOTICE] ";
 
28
        break;
 
29
    case LOG_DEBUG:
 
30
        urgency = "[DEBUG] ";
 
31
        break;
 
32
    default:
 
33
        urgency = "";
 
34
    }
 
35
    if (no_syslog == 0) {
 
36
#ifdef SAVE_DESCRIPTORS
 
37
        openlog("ucarp", LOG_PID, syslog_facility);
 
38
#endif
 
39
        syslog(crit, "%s%s", urgency, line);
 
40
#ifdef SAVE_DESCRIPTORS
 
41
        closelog();
 
42
#endif
 
43
    }    
 
44
    if (daemonize == 0) {
 
45
        switch (crit) {
 
46
        case LOG_WARNING:
 
47
        case LOG_ERR:
 
48
            fprintf(stderr, "%s%s\n", urgency, line);
 
49
            break;
 
50
        default:
 
51
            printf("%s%s\n", urgency, line);
 
52
        }
 
53
    }    
 
54
    va_end(va);
 
55
}