📄 log.h
字号:
// so you can choose how noisy the log is // when you cause an error eg. by deleting // a non-existant log. /*========================================================================. | Dynamic Interface | '========================================================================*/ /** * Return the name of this Log. This is the unique * 'handle' for this log and any calls to the static * method getLog(std::string name) with the returned * value of this method will always return the same log. **/ virtual const std::string& getName() const = 0; /*------------------------------------------------------------------------. | LogOutput Management | '------------------------------------------------------------------------*/ /** * Add a LogOutput to this Log. * @param name The name by which to refer to the * new LogOutput. * @param mask The LogMask to apply to * the new LogOutput. * @param os An optional std::ostream to attach to * the new LogOutput. **/ virtual void addOutput(const std::string& name, const LogMask& mask, std::ostream& os = std::cout) = 0; /** * Modify the LogMask for the default LogOutput of this Log. * @param mask The new LogMask to apply to * the named LogOutput. * @param modType The method by which to apply the new LogMask. **/ virtual void setLogMask(const LogMask& mask, ModType modType = REPLACE) = 0; /** * Modify the LogMask for the default LogOutput of this Log based * on which LogStream LogLevel is required as a minimum to pass * through the LogOutput LogMask. * @param level The new LogMask is calculated from this value such * that it will prevent any LogStream objects of a LogLevel lower than * this from writing to the LogOutput. * @param modType The method by which to apply the new LogMask. **/ virtual void setLogMaskLevel(const LogLevel& level, ModType modType = REPLACE) = 0; /** * Get the LogMask for the default LogOutput of this Log. * @return The LogMask assigned to the default LogOutput * of this Log. **/ virtual LogMask getLogMask() = 0; /** * Modify the LogMask for a LogOutput added to this Log. * @param name The name of the LogOutput to modify. * @param mask The new LogMask to apply to * the named LogOutput. * @param modType The method by which to apply the new LogMask. **/ virtual void setLogMask(const std::string& name, const LogMask& mask, ModType modType = REPLACE) = 0; /** * Modify the LogMask for a LogOutput added to this Log based * on which LogStream LogLevel is required as a minimum to pass * through the LogOutput LogMask. * @param level The new LogMask is calculated from this value such * that it will prevent any LogStream objects of a LogLevel lower than * this from writing to the LogOutput. * @param modType The method by which to apply the new LogMask. **/ virtual void setLogMaskLevel(const std::string& name, const LogLevel& level, ModType modType = REPLACE) = 0; /** * Get the LogMask for a LogOutput added to this Log. * @param name The name of the LogOutput to query. * @return The LogMask assigned to the specified LogOutput * of this Log. **/ virtual LogMask getLogMask(const std::string& name) = 0; /** * Change the internal LogForm formatting object of the * default LogOutput for this Log. * @param name The name of the LogOutput to modify. * @param format The new LogForm object to use. **/ virtual void setLogForm(const class LogForm* const format) = 0; /** * Change the internal LogForm formatting object of a * LogOutput added to this Log. * @param name The name of the LogOutput to modify. * @param format The new LogForm object to use. **/ virtual void setLogForm(const std::string& name, const LogForm* const format) = 0; /** * Delete a LogOutput from this Log. * @param name The name of the LogOutput to delete. **/ virtual void delOutput(const std::string& name) = 0; /*------------------------------------------------------------------------. | std::ostream Management | '------------------------------------------------------------------------*/ /** * Attach an output stream to the default LogOutput * of this Log. * @param os The std::ostream attach. **/ virtual void attachOstream(std::ostream& os) = 0; /** * Remove an output stream from the default LogOutput * of this Log. * @param os The std::ostream remove. **/ virtual void removeOstream(std::ostream& os) = 0; /** * Attach an std::ostream to one of the LogOutput * objects added to this Log. * @param name The name of the LogOutput to attach the std::ostream to. * @param os The std::ostream to attach. **/ virtual void attachOstream(const std::string& name, std::ostream& os) = 0; /** * Remove an ostream from one of the LogOutput * objects added to this Log. * @param name The LogOutput to remove the std::ostream from. * @param os The std::ostream remove. **/ virtual void removeOstream(const std::string& name, std::ostream& os) = 0; // Add new message levels in addition to the builtin // ones, eg. debug(), error(), info(), ... etc. /*------------------------------------------------------------------------. | LogStream Management | '------------------------------------------------------------------------*/ /** * Add an LogStream to this log. * @param name The name by which this new * LogStream will be known. * @param level The LogLevel at which the new LogStream * will operate. **/ virtual void addLogStream(const std::string& name, const LogLevel& level = MAX_LEVEL) = 0; /** * Modify either one of the builtin LogStream objects * or an LogStream attached to this log with * a previous call to addLogStream(std::string, LogLevel). * @param name The name (handle) of the LogStream to modify. * @param level The new LogLevel at which the LogStream * will now operate. **/ virtual void modLogStream(const std::string& name, const LogLevel& level) = 0; /** * Remove an LogStream attached to this log with * a previous call to addLogStream(std::string, LogLevel). * @param name The name (handle) of the LogStream to remove. **/ virtual void delLogStream(const std::string& name) = 0; /*------------------------------------------------------------------------. | User defined LogStream access | '------------------------------------------------------------------------*/ /** * Method to access either one of the builtin LogStream objects * or an LogStream attached to this log with * a previous call to addLogStream(std::string, LogLevel). * @param name The name (handle) of the LogStream to access. **/ virtual LogStream& to(std::string name) = 0; /** * Method to send info to either one of the builtin LogStream objects * or an LogStream attached to this log with * a previous call to addLogStream(std::string, LogLevel). * @param name The name (handle) of the LogStream to access. * @param info The message to send to this LogStream. **/ virtual LogStream& to(std::string name, std::string info) = 0; /** * Start processing the LogMessage queue on the * current thread. Note this method will block * untill a call to stopThread() is made from * another thread. Therefore for the calling * application to achieve a separately threaded * message queue it is the *caller's* responsibility * to initiate the new thread and to call this * method from that thread. * @param threadCall A thread callback object implementing * the (thread library) specifics of threading required * by the Log's queueing system. This object will be * destroyed using 'delete' by the Log **/ //virtual void startThread(ThreadCall* threadCall) = 0; /** * Set the ThreadMill for this Log. * @patam threadMill The ThreadMill to use. **/ virtual void setThreadMill(const class ThreadMill* threadMill) = 0; /** * Begin queueing messages to be dispatched on a * separate background thread. If threading is * not available this call has no effect. **/ virtual void startThread() = 0; /** * Terminate any threads and stop queueing * messages: send them directly to the outputs. **/ virtual void stopThread() = 0; /** * Terminate any threads, close and flush all streams associated * with this Log. **/ virtual void close() = 0;};//=============================================================================LPP_NAMESPACE_END//=============================================================================#endif /*LOG_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -