mirror of
https://github.com/google/santa.git
synced 2026-01-14 00:37:56 -05:00
* review updates * fix test * review updates * log level cleanup Co-authored-by: Tom Burgin <bur@chromium.org> Co-authored-by: Russell Hancox <russellhancox@users.noreply.github.com>
60 lines
1.8 KiB
Objective-C
60 lines
1.8 KiB
Objective-C
/// Copyright 2015 Google Inc. All rights reserved.
|
|
///
|
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
/// you may not use this file except in compliance with the License.
|
|
/// You may obtain a copy of the License at
|
|
///
|
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
///
|
|
/// Unless required by applicable law or agreed to in writing, software
|
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
/// See the License for the specific language governing permissions and
|
|
/// limitations under the License.
|
|
|
|
///
|
|
/// Logging definitions
|
|
///
|
|
|
|
#ifndef SANTA__COMMON__LOGGING_H
|
|
#define SANTA__COMMON__LOGGING_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
typedef enum : NSUInteger {
|
|
LOG_LEVEL_ERROR,
|
|
LOG_LEVEL_WARN,
|
|
LOG_LEVEL_INFO,
|
|
LOG_LEVEL_DEBUG
|
|
} LogLevel;
|
|
|
|
///
|
|
/// Logging function.
|
|
/// @param level one of the levels defined above
|
|
/// @param destination a FILE, generally stdout/stderr. If the file is closed, the log
|
|
/// will instead be sent to syslog.
|
|
/// @param format the printf style format string
|
|
/// @param ... the arguments to format.
|
|
///
|
|
void logMessage(LogLevel level, FILE *destination, NSString *format, ...)
|
|
__attribute__((format(__NSString__, 3, 4)));
|
|
|
|
/// Simple logging macros
|
|
#define LOGD(logFormat, ...) logMessage(LOG_LEVEL_DEBUG, stdout, logFormat, ##__VA_ARGS__)
|
|
#define LOGI(logFormat, ...) logMessage(LOG_LEVEL_INFO, stdout, logFormat, ##__VA_ARGS__)
|
|
#define LOGW(logFormat, ...) logMessage(LOG_LEVEL_WARN, stderr, logFormat, ##__VA_ARGS__)
|
|
#define LOGE(logFormat, ...) logMessage(LOG_LEVEL_ERROR, stderr, logFormat, ##__VA_ARGS__)
|
|
|
|
/// Get the logging level for this process.
|
|
LogLevel EffectiveLogLevel();
|
|
|
|
#ifdef __cplusplus
|
|
} // extern C
|
|
#endif
|
|
|
|
#endif // SANTA__COMMON__LOGGING_H
|