diff options
author | Manuel Bentele | 2020-10-16 17:15:49 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-16 17:15:49 +0200 |
commit | 969496f15e1e0359e26c2c6e995ad4ef82720f86 (patch) | |
tree | 358466216630eb10e8ee91b9ede490424f6db848 /inc/dnbd3/shared/log.h | |
parent | [FUSE] turn on compiler optimization to fix warning (diff) | |
download | dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.tar.gz dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.tar.xz dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.zip |
[BUILD] rewrite CMake build system to track changes of source files
This change restructures the source code directories, separates shared
form non-shared application code and adds CMake dependencies. These
dependencies allow the tracking of changes and trigger a rebuild of
those build targets where changed files are involved.
WARNING: Note that the support of the DNBD3_SERVER_AFL build option is
not supported yet. Thus, the option should be never turned on.
Diffstat (limited to 'inc/dnbd3/shared/log.h')
-rw-r--r-- | inc/dnbd3/shared/log.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/inc/dnbd3/shared/log.h b/inc/dnbd3/shared/log.h new file mode 100644 index 0000000..5b1e8f7 --- /dev/null +++ b/inc/dnbd3/shared/log.h @@ -0,0 +1,65 @@ +/* + * This file is part of the Distributed Network Block Device 3 + * + * Copyright(c) 2011-2012 Simon Rettberg + * + * This file may be licensed under the terms of of the + * GNU General Public License Version 2 (the ``GPL''). + * + * Software distributed under the License is distributed + * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the GPL for the specific language + * governing rights and limitations. + * + * You should have received a copy of the GPL along with this + * program. If not, go to http://www.gnu.org/licenses/gpl.html + * or write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef LOG_H_ +#define LOG_H_ + +#include <stdbool.h> +#include <unistd.h> + +typedef unsigned int logmask_t; +#define LOG_ERROR ((logmask_t)1) // Fatal error, server will terminate +#define LOG_WARNING ((logmask_t)2) // Major issue, something is broken but keep running +#define LOG_MINOR ((logmask_t)4) // Minor issue, more of a hickup than serious problem +#define LOG_INFO ((logmask_t)8) // Informational message +#define LOG_DEBUG1 ((logmask_t)16) // Debug information, use this for non-spammy stuff +#define LOG_DEBUG2 ((logmask_t)32) // Use this for debug messages that will show up a lot + + +/** + * Check if cansoleMask | fileMask has all of mask set. + */ +bool log_hasMask(const logmask_t mask); + +void log_setFileMask(logmask_t mask); + +void log_setConsoleMask(logmask_t mask); + +void log_setConsoleTimestamps(bool on); + +/** + * Open or reopen the log file. If path is NULL and the + * function was called with a path before, the same path + * will be used again. + */ +bool log_openLogFile(const char *path); + +/** + * Add a line to the log + */ +void logadd(const logmask_t mask, const char *text, ...) + __attribute__ ((format (printf, 2, 3))); + +/** + * Return last size bytes of log. + */ +ssize_t log_fetch(char *buffer, int size); + +#endif /* LOG_H_ */ |