7 #ifndef __platform_debug_h__ 8 #define __platform_debug_h__ 13 FE_MEM_PORT
extern String gs_logPrefix;
14 FE_MEM_PORT
extern BWORD gs_bannerPrinted;
19 void FE_DL_EXPORT
vsPrintf(std::string &target,
const char *fmt, va_list ap,
int &size);
24 class FE_DL_PUBLIC
Log 30 virtual void log(
const std::string &a_message) =0;
31 virtual void log(
const std::string &a_message,
32 std::map<std::string,std::string> &a_attributes)
39 RecursiveMutex::Guard guard(mutex());
44 RecursiveMutex::Guard guard(mutex());
50 #if FE_SAFE_COUNTED_MUTEX 51 virtual RecursiveMutex& mutex(
void)
const 52 {
return *ms_pMutex; }
55 static FE_DL_PUBLIC I32 ms_mutexCount;
56 static FE_DL_PUBLIC RecursiveMutex* ms_pMutex;
58 virtual RecursiveMutex& mutex(
void)
const 61 static FE_DL_PUBLIC RecursiveMutex ms_mutex;
67 FE_DL_PUBLIC
void intrusive_ptr_add_ref(
Log *a_log);
68 FE_DL_PUBLIC
void intrusive_ptr_release(
Log *a_log);
73 class FE_DL_PUBLIC StdoutLog :
public Log 77 virtual ~StdoutLog(
void) {}
79 virtual void log(
const std::string &a_message,
80 std::map<std::string,std::string> &a_attributes);
81 virtual void log(
const std::string &a_message)
83 std::cout << a_message.c_str();
88 class FE_DL_PUBLIC FileLog :
public StdoutLog
92 virtual ~FileLog(
void) {}
96 virtual void log(
const std::string &a_message,
97 std::map<std::string,std::string> &a_attributes);
99 void setFilename(
String a_filename);
100 String filename(
void) {
return m_filename; }
104 std::ofstream m_ofstream;
107 class FE_DL_PUBLIC AnnotatedLog :
public StdoutLog
110 AnnotatedLog(
void): m_newline(
true) {}
111 virtual ~AnnotatedLog(
void) {}
113 using StdoutLog::log;
115 virtual void log(
const std::string &a_message,
116 std::map<std::string,std::string> &a_attributes);
118 void output(std::ostream& stream,
const char* source,
119 int size,
bool right);
123 class FE_DL_PUBLIC PrefaceLog :
public AnnotatedLog
127 virtual ~PrefaceLog(
void) {}
129 using AnnotatedLog::log;
131 virtual void log(
const std::string &a_message,
132 std::map<std::string,std::string> &a_attributes);
134 virtual String preface(
void) {
return m_logPreface; }
135 virtual void setPreface(
String a_preface) { m_logPreface=a_preface; }
143 class FE_DL_PUBLIC PrefixLog :
public PrefaceLog
147 virtual ~PrefixLog(
void) {}
149 using PrefaceLog::log;
151 virtual String preface(
void) {
return gs_logPrefix; }
153 static String prefix(
void) {
return gs_logPrefix; }
154 void setPrefix(
String a_prefix) { gs_logPrefix=a_prefix; }
157 class FE_DL_PUBLIC GroupLog :
public AnnotatedLog
161 virtual ~GroupLog(
void) {}
163 using AnnotatedLog::log;
165 virtual void log(
const std::string &a_message,
166 std::map<std::string,std::string> &a_attributes);
169 class FE_DL_PUBLIC NullLog :
public Log 173 virtual ~NullLog(
void) {}
177 virtual void log(
const std::string &a_message)
183 class FE_DL_PUBLIC Win32Log :
public Log 187 virtual ~Win32Log(
void) {}
191 virtual void log(
const std::string &a_message)
193 #if FE_OS==FE_WIN32 || FE_OS==FE_WIN64 194 OutputDebugStringA(a_message.c_str());
299 virtual void log(
const String &a_group,
300 std::map<std::string,std::string> &a_attributes,
301 const char *a_format, ...);
302 virtual void bind(
const String &a_group,
const String &a_logname);
303 virtual void antibind(
const String &a_group,
const String &a_logname);
304 virtual void clear(
const String &a_group);
305 virtual void clearAll(
void);
306 virtual void setLog(
const String &a_logname, t_logptr a_log);
308 virtual void dump(
void);
313 void wiregroup(
const String &a_group);
314 std::map<String, std::vector<String> > m_bindings;
315 std::map<String, std::vector<String> > m_antibindings;
316 std::map<String, t_logptr> m_logs;
317 t_logptr m_directLog;
319 std::map<String, std::vector<t_logptr> > m_bindmap;
321 #if FE_SAFE_COUNTED_MUTEX 322 virtual RecursiveMutex& mutex(
void)
const 323 {
return *ms_pMutex; }
326 static FE_DL_PUBLIC I32 ms_mutexCount;
327 static FE_DL_PUBLIC RecursiveMutex* ms_pMutex;
329 virtual RecursiveMutex& mutex(
void)
const 332 static FE_DL_PUBLIC RecursiveMutex ms_mutex;
353 #define feLog(...) { \ 354 std::stringstream out; \ 356 std::map<std::string,std::string> attributes; \ 357 attributes["file"] = __FILE__; \ 358 attributes["line"] = out.str().c_str(); \ 359 attributes["date"] = __DATE__; \ 360 attributes["time"] = __TIME__; \ 361 attributes["group"] = MODULE; \ 362 feLogger()->log(MODULE, attributes, __VA_ARGS__); \ 365 #define feLogGroup(grp, ...) { \ 366 std::stringstream out; \ 368 std::map<std::string,std::string> attributes; \ 369 attributes["file"] = __FILE__; \ 370 attributes["line"] = out.str().c_str(); \ 371 attributes["date"] = __DATE__; \ 372 attributes["time"] = __TIME__; \ 373 attributes["group"] = grp; \ 374 feLogger()->log(grp, attributes, __VA_ARGS__); \ 377 #define feLog(...) { feLogDirect(__VA_ARGS__); } 378 #define feLogGroup(grp,...) { feLogDirect(__VA_ARGS__); } 382 FE_DL_PUBLIC
void feLogDirect(
const char *format, ...);
384 FE_DL_PUBLIC
void feLogError(
const char *format, ...);
C++ portion of logging interface implementation.
Definition: debug.h:292
kernel
Definition: namespace.dox:3
void vsPrintf(std::string &target, const char *fmt, va_list ap, int &size)
Format text into a fe::String.
Definition: debug.cc:252
Automatically reference-counted string container.
Definition: String.h:128
Base class for logging system Log objects.
Definition: debug.h:24