]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_utilities/lib/logging.cpp
2 * Copyright (c) 2000-2004,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // logging - message log support
32 #include <security_utilities/logging.h>
33 #include <security_utilities/globalizer.h>
44 // Open and initialize logging
46 void open(const char *ident
, int facility
, int options
/*= 0*/)
48 ::openlog(ident
, options
, facility
);
53 // General output method
56 static void output(int priority
, const char *format
, va_list args
) __attribute__((format(printf
, 2, 0)));
59 static void output(int priority
, const char *format
, va_list args
)
61 ::vsyslog(priority
, format
, args
);
66 // Priority-specific wrappers
68 void syslog(int priority
, const char *format
, ...)
69 { va_list args
; va_start(args
, format
); output(priority
, format
, args
); va_end(args
); }
71 void emergency(const char *format
, ...)
72 { va_list args
; va_start(args
, format
); output(LOG_EMERG
, format
, args
); va_end(args
); }
73 void alert(const char *format
, ...)
74 { va_list args
; va_start(args
, format
); output(LOG_ALERT
, format
, args
); va_end(args
); }
75 void critical(const char *format
, ...)
76 { va_list args
; va_start(args
, format
); output(LOG_CRIT
, format
, args
); va_end(args
); }
77 void error(const char *format
, ...)
78 { va_list args
; va_start(args
, format
); output(LOG_ERR
, format
, args
); va_end(args
); }
79 void warning(const char *format
, ...)
80 { va_list args
; va_start(args
, format
); output(LOG_WARNING
, format
, args
); va_end(args
); }
81 void notice(const char *format
, ...)
82 { va_list args
; va_start(args
, format
); output(LOG_NOTICE
, format
, args
); va_end(args
); }
83 void info(const char *format
, ...)
84 { va_list args
; va_start(args
, format
); output(LOG_INFO
, format
, args
); va_end(args
); }
85 void debug(const char *format
, ...)
86 { va_list args
; va_start(args
, format
); output(LOG_DEBUG
, format
, args
); va_end(args
); }
90 // Enable mask operation
95 ::setlogmask(mask
= ::setlogmask(0));
99 void upto(int priority
)
101 ::setlogmask(LOG_UPTO(priority
));
104 void enable(int priority
)
106 ::setlogmask(::setlogmask(0) | LOG_MASK(priority
));
109 void disable(int priority
)
111 ::setlogmask(::setlogmask(0) & ~LOG_MASK(priority
));
114 } // end namespace Syslog
116 } // end namespace Security