Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:12

0001 /*
0002  * This File is part of Davix, The IO library for HTTP based protocols
0003  * Copyright (C) CERN 2013
0004  * Author: Adrien Devresse <adrien.devresse@cern.ch>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020 */
0021 
0022 #ifndef DAVIX_LOGGER_HPP
0023 #define DAVIX_LOGGER_HPP
0024 
0025 #include <cstdarg>
0026 #include <utils/davix_types.hpp>
0027 
0028 
0029 
0030 namespace Davix{
0031 
0032 
0033 // log level
0034 #define DAVIX_LOG_CRITICAL  1
0035 #define DAVIX_LOG_WARNING   2
0036 #define DAVIX_LOG_VERBOSE   3
0037 #define DAVIX_LOG_DEBUG     4
0038 #define DAVIX_LOG_TRACE     5
0039 #define DAVIX_LOG_ALL       6
0040 
0041 // log scope
0042 #define DAVIX_LOG_FILE       (1<<0)
0043 #define DAVIX_LOG_POSIX      (1<<1)
0044 #define DAVIX_LOG_XML        (1<<2)
0045 #define DAVIX_LOG_SSL        (1<<3)
0046 #define DAVIX_LOG_HEADER     (1<<4)
0047 #define DAVIX_LOG_BODY       (1<<5)
0048 #define DAVIX_LOG_CHAIN      (1<<6)
0049 #define DAVIX_LOG_CORE       (1<<7)
0050 #define DAVIX_LOG_GRID       (1<<8)
0051 #define DAVIX_LOG_SOCKET     (1<<9)
0052 #define DAVIX_LOG_LOCKS      (1<<10)
0053 #define DAVIX_LOG_HTTP       (1<<11)
0054 #define DAVIX_LOG_S3         (1<<12)
0055 #define DAVIX_LOG_SENSITIVE  (1<<13)
0056 #define DAVIX_LOG_SCOPE_NEON (1<<29)
0057 #define DAVIX_LOG_SCOPE_ALL        (~(0) ^ DAVIX_LOG_BODY)
0058 
0059 // define string for log scopes
0060 extern const char* SCOPE_FILE;      // Davix file interface
0061 extern const char* SCOPE_HTTP;      // Http Request Scope
0062 extern const char* SCOPE_S3;        // S3 authentication info
0063 extern const char* SCOPE_POSIX;     // Davix posix interface
0064 extern const char* SCOPE_XML;       // XML info and parser output
0065 extern const char* SCOPE_SSL;       // SSL and cert details
0066 extern const char* SCOPE_HEADER;    // Request and respond headers
0067 extern const char* SCOPE_BODY;      // HTTP bodies
0068 extern const char* SCOPE_CHAIN;     // IO chains info
0069 extern const char* SCOPE_CORE;      // Config and misc info
0070 extern const char* SCOPE_GRID;      // Misc info from 3rd parties
0071 extern const char* SCOPE_SOCKET;    // Socket info
0072 extern const char* SCOPE_LOCKS;     // WebDAV locking info
0073 extern const char* SCOPE_SENSITIVE; // Sensitive information
0074 extern const char* SCOPE_ALL;       // All of the above
0075 
0076 
0077 // log a string to the Davix logger system
0078 void logStr(int scope, int log_level, const std::string & str);
0079 
0080 ///
0081 /// \brief getLogLevel
0082 /// \return current davix Logger level
0083 ///
0084 int getLogLevel();
0085 ///
0086 /// \brief setLogLevel
0087 /// \param logLevel
0088 ///
0089 /// define davix logger level
0090 void setLogLevel(int logLevel);
0091 
0092 ///
0093 /// \brief getLogScope
0094 /// \return current davix scope mask
0095 ///
0096 int getLogScope();
0097 
0098 ///
0099 /// \brief setLogScope
0100 ///
0101 ///  define davix scope mask.
0102 ///  Only the components covered by the mask will be available via the logging
0103 void setLogScope(int mask);
0104 ///
0105 /// \brief setLogScope
0106 /// \param scope
0107 /// define davix scope mask from a list of string separated by comma
0108 void setLogScope(const std::string & scope);
0109 
0110 
0111 ///
0112 /// \brief getScopeName
0113 /// \param scope_mask
0114 /// \return scope name of the first scope that match the mask
0115 ///  if none match, return ALL
0116 ///
0117 std::string getScopeName(int scope_mask);
0118 
0119 } // Davix
0120 
0121 
0122 
0123 
0124 DAVIX_C_DECL_BEGIN
0125 
0126 
0127 
0128 /// set the davix log mask
0129 /// everything that is not covered by the mask is dropped
0130 extern DAVIX_EXPORT void davix_set_log_level(int log_mask);
0131 
0132 /// get current log mask
0133 extern DAVIX_EXPORT int davix_get_log_level();
0134 
0135 /// internal logger function
0136 extern DAVIX_EXPORT void davix_logger(int log_mask, const char * msg, ...);
0137 
0138 /// variadic version of internal logger function
0139 extern DAVIX_EXPORT void davix_vlogger(int log_mask, const char* msg, va_list args);
0140 
0141 
0142 /// @brief setup a log handler
0143 ///
0144 /// redirect the davix log output to the function f_handler
0145 /// setting up a log handler disable the std output log
0146 ///
0147 /// @param fhandler : log handler callback
0148 /// @param userdata : callback userdata
0149 extern DAVIX_EXPORT void davix_set_log_handler( void (*fhandler)(void* userdata, int mgs_level, const char* msg), void* userdata);
0150 
0151 
0152 DAVIX_C_DECL_END
0153 
0154 #endif // DAVIX_LOGGER_HPP