]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/logging.cpp
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // logging - message log support
26 #include <Security/logging.h>
27 #include <Security/globalizer.h>
38 // Open and initialize logging
40 void open(const char *ident
, int facility
, int options
/*= 0*/)
42 ::openlog(ident
, options
, facility
);
47 // General output method
49 static void output(int priority
, const char *format
, va_list args
)
51 ::vsyslog(priority
, format
, args
);
56 // Priority-specific wrappers
58 void syslog(int priority
, const char *format
, ...)
59 { va_list args
; va_start(args
, format
); output(priority
, format
, args
); va_end(args
); }
61 void emergency(const char *format
, ...)
62 { va_list args
; va_start(args
, format
); output(LOG_EMERG
, format
, args
); va_end(args
); }
63 void alert(const char *format
, ...)
64 { va_list args
; va_start(args
, format
); output(LOG_ALERT
, format
, args
); va_end(args
); }
65 void critical(const char *format
, ...)
66 { va_list args
; va_start(args
, format
); output(LOG_CRIT
, format
, args
); va_end(args
); }
67 void error(const char *format
, ...)
68 { va_list args
; va_start(args
, format
); output(LOG_ERR
, format
, args
); va_end(args
); }
69 void warning(const char *format
, ...)
70 { va_list args
; va_start(args
, format
); output(LOG_WARNING
, format
, args
); va_end(args
); }
71 void notice(const char *format
, ...)
72 { va_list args
; va_start(args
, format
); output(LOG_NOTICE
, format
, args
); va_end(args
); }
73 void info(const char *format
, ...)
74 { va_list args
; va_start(args
, format
); output(LOG_INFO
, format
, args
); va_end(args
); }
75 void debug(const char *format
, ...)
76 { va_list args
; va_start(args
, format
); output(LOG_DEBUG
, format
, args
); va_end(args
); }
80 // Enable mask operation
85 ::setlogmask(mask
= ::setlogmask(0));
89 void upto(int priority
)
91 ::setlogmask(LOG_UPTO(priority
));
94 void enable(int priority
)
96 ::setlogmask(::setlogmask(0) | LOG_MASK(priority
));
99 void disable(int priority
)
101 ::setlogmask(::setlogmask(0) & ~LOG_MASK(priority
));
104 } // end namespace Syslog
106 } // end namespace Security