Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
qpid/log/Logger.h
Go to the documentation of this file.
00001 #ifndef QPID_LOG_LOGGER_H
00002 #define QPID_LOG_LOGGER_H
00003 
00004 /*
00005  *    http://www.apache.org/licenses/LICENSE-2.0
00006  *
00007  * Unless required by applicable law or agreed to in writing, software
00008  * distributed under the License is distributed on an "AS IS" BASIS,
00009  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00010  * See the License for the specific language governing permissions and
00011  * limitations under the License.
00012  *
00013  */
00014 
00015 #include "qpid/log/Selector.h"
00016 #include "qpid/log/Options.h"
00017 #include "qpid/sys/Mutex.h"
00018 #include <boost/ptr_container/ptr_vector.hpp>
00019 #include <boost/noncopyable.hpp>
00020 #include <set>
00021 #include "qpid/CommonImportExport.h"
00022 
00023 namespace qpid {
00024 namespace log {
00025 
00036 class QPID_COMMON_CLASS_EXTERN Logger : private boost::noncopyable {
00037   public:
00039     enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32, HIRES=64};
00040 
00050     class Output {
00051       public:
00052         QPID_COMMON_EXTERN Output();
00053         QPID_COMMON_EXTERN virtual ~Output();
00055         virtual void log(const Statement&, const std::string&) =0;
00056     };
00057 
00058     QPID_COMMON_EXTERN static Logger& instance();
00059 
00060     QPID_COMMON_EXTERN Logger();
00061     QPID_COMMON_EXTERN ~Logger();
00062 
00064     QPID_COMMON_EXTERN void select(const Selector& s);
00065 
00067     QPID_COMMON_EXTERN void format(int formatFlags);
00068 
00072     QPID_COMMON_EXTERN int format(const Options&);
00073 
00075     QPID_COMMON_EXTERN void configure(const Options& o);
00076 
00078     QPID_COMMON_EXTERN void reconfigure(const std::vector<std::string>& selectors);
00079 
00081     QPID_COMMON_EXTERN void add(Statement& s);
00082 
00084     QPID_COMMON_EXTERN void log(const Statement&, const std::string&);
00085 
00087     QPID_COMMON_EXTERN void output(std::auto_ptr<Output> out);
00088 
00090     QPID_COMMON_EXTERN void setPrefix(const std::string& prefix);
00091 
00093     QPID_COMMON_EXTERN void clear();
00094 
00096     QPID_COMMON_INLINE_EXTERN const Options& getOptions() const { return options; }
00097 
00098 
00099   private:
00100     typedef boost::ptr_vector<Output> Outputs;
00101     typedef std::set<Statement*> Statements;
00102 
00103     sys::Mutex lock;
00104     inline void enable_unlocked(Statement* s);
00105 
00106     Statements statements;
00107     Outputs outputs;
00108     Selector selector;
00109     int flags;
00110     std::string prefix;
00111     Options options;
00112 };
00113 
00114 }} // namespace qpid::log
00115 
00116 
00117 #endif  

Qpid C++ API Reference
Generated on Mon Aug 22 2011 for Qpid C++ Client API by doxygen 1.7.4