📄 warlog.h
字号:
/** @name Log handling** #include "WarLog.h" ** @doc The logging is handled by an iostream* alike (but not compatible) class, WarLog.* In order to log events, WarLog ovjects are* created on demand, each bound to the type* of event one wants to log.** \begin{verbatim}* WarLog errlog(WARLOG_ERROR, "main()");* errlog << "This is a test" << war_endl;* \end{verbatim}** The WarLog object checks if the type is* represent is currently being logged, and if so,* queues the log until a war_endl object is* reached. At that time, a log-event is built, and* the event passed to the installed log-handler chain.* The log can be written to the console, to one or* more files, to system logs or wherever the* log-event handlers sends them.** Incomplete log-lines are trashed when the WarLog* object dies.** If a WarLog object is created for a an event type that * is not logged, the object simply igores its input.*//**@{ */#ifndef WAR_LOG_H#define WAR_LOG_H/* SYSTEM INCLUDES */#ifndef WAR_STRSTREAM_INCLUDED# define WAR_STRSTREAM_INCLUDED# include <strstream>#endif/* PROJECT INCLUDES */#ifndef WAR_COLLECTOR_H# include "WarCollector.h"#endif#ifndef WAR_LOG_EVENT_H# include "WarLogEvent.h"#endif#ifndef WAR_LOG_ENGINE_H# include "WarLogEngine.h"#endif#ifndef WAR_LOG_IDENTIFIER_H# include "WarLogIdentifier.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES *//// Emergancy function for error-reporting in exception handlersvoid WarLogError(war_ccstr_t func, war_ccstr_t message, WarException *pexception);#ifdef __cplusplusextern "C" {#endif /****************** BEGIN OLD STYLE C spesific ********/ /****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplus/** The log interface external API*/class WarLog : public WarCollector<char>{public: // LIFECYCLE /** * Default constructor. */ WarLog(WarLogEventTypeE logType, war_ccstr_t logFunction, WarLogIdentifier *pidentifier = NULL); /** * Destructor. */ virtual ~WarLog(void); // OPERATORS /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarLog& operator=(WarLog& from); /** * Check if the log-event is actoive */ operator bool () const; // OPERATIONS // ACCESS /** Query which log event this object streams */ const WarLogEventTypeE GetType() const { return mType; }; // INQUIRY static const char sTypeChr[WARLOG_INVALID + 1]; static const char *sTypeString[WARLOG_INVALID + 1]; virtual WarCollector<char>& AddEndln(const war_endl_e& from) { Submit(); return *this; } virtual WarCollector<char>& AddError(const WarError& from) { if (mpData) mpData->mError = from; return *this; } static WarLogEventTypeE Lookup(war_ccstr_t eventName);protected: void Submit(); WarLogEventData *mpData; WarLogEventTypeE mType; WarLogIdentifier mIdentifier;private:};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* _WAR_LOG_H_ *//**@} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -