2015-05-15 05:44:48 +08:00
|
|
|
/*
|
|
|
|
|
|
|
|
nsjail - logging
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
Copyright 2014 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.
|
|
|
|
|
|
|
|
*/
|
2016-03-02 00:03:11 +08:00
|
|
|
|
2016-03-11 09:45:43 +08:00
|
|
|
#ifndef NS_LOG_H
|
|
|
|
#define NS_LOG_H
|
2015-05-15 05:44:48 +08:00
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2017-10-18 20:27:34 +08:00
|
|
|
#include "nsjail.h"
|
2015-05-15 05:44:48 +08:00
|
|
|
|
2015-10-17 09:51:35 +08:00
|
|
|
#define LOG_HELP(...) logLog(HELP, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
#define LOG_HELP_BOLD(...) logLog(HELP_BOLD, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
|
|
|
|
#define LOG_D(...) logLog(DEBUG, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
#define LOG_I(...) logLog(INFO, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
#define LOG_W(...) logLog(WARNING, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
#define LOG_E(...) logLog(ERROR, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
#define LOG_F(...) logLog(FATAL, __func__, __LINE__, false, __VA_ARGS__);
|
|
|
|
|
|
|
|
#define PLOG_D(...) logLog(DEBUG, __func__, __LINE__, true, __VA_ARGS__);
|
|
|
|
#define PLOG_I(...) logLog(INFO, __func__, __LINE__, true, __VA_ARGS__);
|
|
|
|
#define PLOG_W(...) logLog(WARNING, __func__, __LINE__, true, __VA_ARGS__);
|
|
|
|
#define PLOG_E(...) logLog(ERROR, __func__, __LINE__, true, __VA_ARGS__);
|
|
|
|
#define PLOG_F(...) logLog(FATAL, __func__, __LINE__, true, __VA_ARGS__);
|
2015-05-15 05:44:48 +08:00
|
|
|
|
2018-02-08 22:24:17 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-10-09 05:00:45 +08:00
|
|
|
bool logInitLogFile(struct nsjconf_t* nsjconf);
|
|
|
|
void logLog(enum llevel_t ll, const char* fn, int ln, bool perr, const char* fmt, ...)
|
|
|
|
__attribute__((format(printf, 5, 6)));
|
2015-05-15 05:44:48 +08:00
|
|
|
void logStop(int sig);
|
|
|
|
|
2018-02-08 22:24:17 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2017-10-09 05:00:45 +08:00
|
|
|
#endif /* NS_LOG_H */
|