📄 traceimpl.hpp
字号:
//// This file is part of the "More for C++" library//// Copyright (c) 1999-2003 by Thorsten Goertz (thorsten@morefor.org)//// The "More for C++" library is free software; you can redistribute it and/or// modify it under the terms of the license that comes with this package.//// Read "license.txt" for more details.//// THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES// OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.////////////////////////////////////////////////////////////////////////////////#ifndef TRACEIMPL_HPP#define TRACEIMPL_HPP////////////////////////////////////////////////////////////////////////////////#include <more/stl.hpp>#include <more/io/streams.hpp>#include <more/os/mutex.hpp>#include <more/util/ostreamadapter.hpp>#include <more/util/singleton.hpp>#include <more/util/trace.hpp>#include "singletoncreator.hpp"////////////////////////////////////////////////////////////////////////////////namespace more{ namespace util { class TraceImpl: public more::util::Singleton<TraceImpl> { public: TraceImpl( ); void destroy( ); void addLevel( const Trace::Level& Level ); void removeLevel( size_t nLevel ); p<Trace::LevelMap> getLevels( ); void addPort( const p<Trace::Port>& ); void removePort( const p<Trace::Port>& ); bool accept( size_t nLevel ); void dump( size_t nLevel, const String& sMessage ); private: static SingletonCreator<TraceImpl> singletonCreator; typedef more::stl::Set<p<Trace::Port> > Ports; p<more::os::Mutex> m_pMutex; p<Trace::LevelMap> m_pLevelMap; p<Ports> m_pPorts; }; typedef more::stl::Map<size_t, String> LevelMap; class LogConsole: public Trace::Port { public: LogConsole( size_t nMinLevel ); virtual bool accept( size_t nLevel ) const; virtual void dump( size_t nLevel, const String& sMessage ); private: p<more::os::Mutex> m_pMutex; size_t m_nMinLevel; p<LevelMap> m_pLevelMap; p<OStreamAdapter> m_pOStreamAdapter; }; class LogFile: public Trace::Port { public: LogFile( const String& sLogFile, size_t nMinLevel ); virtual bool accept( size_t nLevel ) const; virtual void dump( size_t nLevel, const String& sMessage ); private: p<more::os::Mutex> m_pMutex; String m_sLogFile; p<more::io::OutputStream> m_pOutputStream; size_t m_nMinLevel; p<LevelMap> m_pLevelMap; }; }}////////////////////////////////////////////////////////////////////////////////#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -