1 /// \file htslib/hts_log.h
2 /// Configuration of log levels.
4 Copyright (C) 2017 Genome Research Ltd.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40 HTS_LOG_OFF
, ///< All logging disabled.
41 HTS_LOG_ERROR
, ///< Logging of errors only.
42 HTS_LOG_WARNING
= 3, ///< Logging of errors and warnings.
43 HTS_LOG_INFO
, ///< Logging of errors, warnings, and normal but significant events.
44 HTS_LOG_DEBUG
, ///< Logging of all except the most detailed debug events.
45 HTS_LOG_TRACE
///< All logging enabled.
48 /// Sets the selected log level.
49 void hts_set_log_level(enum htsLogLevel level
);
51 /// Gets the selected log level.
52 enum htsLogLevel
hts_get_log_level();
54 /// Selected log level.
56 * One of the HTS_LOG_* values. The default is HTS_LOG_WARNING.
57 * \note Avoid direct use of this variable. Use hts_set_log_level and hts_get_log_level instead.
59 extern int hts_verbose
;
62 * \param severity Severity of the event:
63 * - HTS_LOG_ERROR means that something went wrong so that a task could not be completed.
64 * - HTS_LOG_WARNING means that something unexpected happened, but that execution can continue, perhaps in a degraded mode.
65 * - HTS_LOG_INFO means that something normal but significant happened.
66 * - HTS_LOG_DEBUG means that something normal and insignificant happened.
67 * - HTS_LOG_TRACE means that something happened that might be of interest when troubleshooting.
68 * \param context Context where the event occurred. Typically set to "__func__".
69 * \param format Format string with placeholders, like printf.
71 void hts_log(enum htsLogLevel severity
, const char *context
, const char *format
, ...)
72 HTS_FORMAT(printf
, 3, 4);
74 /*! Logs an event with severity HTS_LOG_ERROR and default context. Parameters: format, ... */
75 #define hts_log_error(...) hts_log(HTS_LOG_ERROR, __func__, __VA_ARGS__)
77 /*! Logs an event with severity HTS_LOG_WARNING and default context. Parameters: format, ... */
78 #define hts_log_warning(...) hts_log(HTS_LOG_WARNING, __func__, __VA_ARGS__)
80 /*! Logs an event with severity HTS_LOG_INFO and default context. Parameters: format, ... */
81 #define hts_log_info(...) hts_log(HTS_LOG_INFO, __func__, __VA_ARGS__)
83 /*! Logs an event with severity HTS_LOG_DEBUG and default context. Parameters: format, ... */
84 #define hts_log_debug(...) hts_log(HTS_LOG_DEBUG, __func__, __VA_ARGS__)
86 /*! Logs an event with severity HTS_LOG_TRACE and default context. Parameters: format, ... */
87 #define hts_log_trace(...) hts_log(HTS_LOG_TRACE, __func__, __VA_ARGS__)
93 #endif // #ifndef HTS_LOG_H