00001 // Logging utilities. 00002 // 00003 // Note that the Symbian implementation does not depend on the 00004 // standard C library. Rather basic Symbian libraries and RFileLogger 00005 // are enough. This is to avoid an Open C dependency for such commonly 00006 // required functionality. 00007 // 00008 // The non-Symbian implementation is using standard C libraries only, 00009 // for maximum portability. 00010 // 00011 // Note that regardless of implementation, we require that logging be 00012 // best effort, i.e. that failure to log in itself never disrupt the 00013 // rest of the program. So, for instance, there must never be a 00014 // non-local return from these functions, nor should anything invoke 00015 // abort(), even if there is an out of memory error, or exhaustion of 00016 // file handles, or whatever. 00017 // 00018 // !concept {:name => "Portable logging", :desc => "Logging to a file on Symbian, and to console elsewhere."} 00019 00020 #ifndef __LOGGING_C_H__ 00021 #define __LOGGING_C_H__ 00022 00023 // Note that in this API, the "logfile" argument must always be given 00024 // as an ASCII string. 00025 00026 #include "application_config.h" 00027 00028 // Whether or not to do logging is controlled by the __DO_LOGGING__ 00029 // flag alone. Logging is done differently on different platforms, 00030 // however. 00031 #if __DO_LOGGING__ 00032 00033 #define WHEN_LOGGING(_act) { _act; } 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 #if defined(__EPOC32__) 00040 void log_clear(const char *logfile); 00041 #else 00042 #define log_clear(logfile) ((void)0) 00043 #endif 00044 00045 void log_text(const char *logfile, const char *s); 00046 void __log_ctx(const char *logfile, const char *func, const char *file, int line, const char *s); 00047 void log_fmt(const char* logfile, const char* fmt, ...); 00048 00049 #define log_ctx(logfile,s) __log_ctx(logfile, __func__, __FILE__, __LINE__, s) 00050 00051 #if defined(__EPOC32__) 00052 void epoc_log_assert(const char *func, const char *file, int line, const char *s); 00053 #endif 00054 00055 #ifdef __cplusplus 00056 } 00057 #endif 00058 00059 #else // no logging 00060 00061 #define WHEN_LOGGING(_act) 00062 00063 #define log_clear(logfile) ((void)0) 00064 #define log_text(logfile,s) ((void)0) 00065 #define log_ctx(logfile,s) ((void)0) 00066 #define log_fmt(logfile,f...) ((void)0) 00067 00068 #if defined(__EPOC32__) 00069 #define epoc_log_assert(func,file,line,s) ((void)0) 00070 #endif 00071 00072 #endif // no logging 00073 00074 #define logt(s) log_text(PRIMARY_LOG_FILENAME, s) 00075 #define logc(s) log_ctx(PRIMARY_LOG_FILENAME, s) 00076 #define logg(f...) log_fmt(PRIMARY_LOG_FILENAME, f) 00077 #define logh() log_ctx(PRIMARY_LOG_FILENAME, "") 00078 00079 #endif // __LOGGING_C_H__ 00080 00081 /** 00082 00083 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00084 and the authors. All rights reserved. 00085 00086 Authors: Tero Hasu <tero.hasu@hut.fi> 00087 00088 Permission is hereby granted, free of charge, to any person 00089 obtaining a copy of this software and associated documentation files 00090 (the "Software"), to deal in the Software without restriction, 00091 including without limitation the rights to use, copy, modify, merge, 00092 publish, distribute, sublicense, and/or sell copies of the Software, 00093 and to permit persons to whom the Software is furnished to do so, 00094 subject to the following conditions: 00095 00096 The above copyright notice and this permission notice shall be 00097 included in all copies or substantial portions of the Software. 00098 00099 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00100 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00101 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00102 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00103 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00104 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00105 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00106 SOFTWARE. 00107 00108 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1