summaryrefslogtreecommitdiffstats
path: root/lib/base/ereport.cpp
blob: 4b8c8e062d411a021331f998d4c8c5d6ded1cbd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/** BEGIN COPYRIGHT BLOCK
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
/*
 * ereport.c:  Records transactions, reports errors to administrators, etc.
 * 
 * Rob McCool
 */


#include "private/pprio.h" /* for nspr20 binary release */
#include "netsite.h"
#include "file.h"      /* system_fopenWA, system_write_atomic */
#include "util.h"      /* util_vsprintf */
#include "ereport.h"
#include "slapi-plugin.h"

#include "base/dbtbase.h"

#include <stdarg.h>
#include <stdio.h>      /* vsprintf */
#include <string.h>     /* strcpy */
#include <time.h>       /* localtime */

/* taken from ACL plugin acl.h */
#define ACL_PLUGIN_NAME "NSACLPlugin"

NSAPI_PUBLIC int ereport_v(int degree, char *fmt, va_list args)
{
    char errstr[MAX_ERROR_LEN];

    util_vsnprintf(errstr, MAX_ERROR_LEN, fmt, args);
    switch (degree) 
    {
        case LOG_WARN:
        case LOG_FAILURE:
        case LOG_INFORM:
        case LOG_VERBOSE:
        case LOG_MISCONFIG:
//            slapi_log_error(SLAPI_LOG_PLUGIN, ACL_PLUGIN_NAME, errstr);
            break;
        case LOG_SECURITY:
//            slapi_log_error(SLAPI_LOG_ACL, ACL_PLUGIN_NAME, errstr);
            break;
        case LOG_CATASTROPHE:
//            slapi_log_error(SLAPI_LOG_FATAL, ACL_PLUGIN_NAME, errstr);
            break;
	default:
            break;
    }
    return IO_OKAY;
}

NSAPI_PUBLIC int ereport(int degree, char *fmt, ...)
{
    va_list args;
    int rv;
    va_start(args, fmt);
    rv = ereport_v(degree, fmt, args);
    va_end(args);
    return rv;
}