]>
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
55 static void output(int priority
, const char *format
, va_list args
)
57 ::vsyslog(priority
, format
, args
);
62 // Priority-specific wrappers
64 void syslog(int priority
, const char *format
, ...)
65 { va_list args
; va_start(args
, format
); output(priority
, format
, args
); va_end(args
); }
67 void emergency(const char *format
, ...)
68 { va_list args
; va_start(args
, format
); output(LOG_EMERG
, format
, args
); va_end(args
); }
69 void alert(const char *format
, ...)
70 { va_list args
; va_start(args
, format
); output(LOG_ALERT
, format
, args
); va_end(args
); }
71 void critical(const char *format
, ...)
72 { va_list args
; va_start(args
, format
); output(LOG_CRIT
, format
, args
); va_end(args
); }
73 void error(const char *format
, ...)
74 { va_list args
; va_start(args
, format
); output(LOG_ERR
, format
, args
); va_end(args
); }
75 void warning(const char *format
, ...)
76 { va_list args
; va_start(args
, format
); output(LOG_WARNING
, format
, args
); va_end(args
); }
77 void notice(const char *format
, ...)
78 { va_list args
; va_start(args
, format
); output(LOG_NOTICE
, format
, args
); va_end(args
); }
79 void info(const char *format
, ...)
80 { va_list args
; va_start(args
, format
); output(LOG_INFO
, format
, args
); va_end(args
); }
81 void debug(const char *format
, ...)
82 { va_list args
; va_start(args
, format
); output(LOG_DEBUG
, format
, args
); va_end(args
); }
86 // Enable mask operation
91 ::setlogmask(mask
= ::setlogmask(0));
95 void upto(int priority
)
97 ::setlogmask(LOG_UPTO(priority
));
100 void enable(int priority
)
102 ::setlogmask(::setlogmask(0) | LOG_MASK(priority
));
105 void disable(int priority
)
107 ::setlogmask(::setlogmask(0) & ~LOG_MASK(priority
));
110 } // end namespace Syslog
112 } // end namespace Security