lib: added back m_seen_usb_error check in DefaultRead()
[barry.git] / src / log.h
blobd4416451604d836392d5680da976ff888c6dd8e9
1 ///
2 /// \file log.h
3 /// General header for the Barry library
4 ///
6 /*
7 Copyright (C) 2008-2010, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_LOG_H__
23 #define __BARRY_LOG_H__
25 #include "dll.h"
26 #include <iomanip>
28 namespace Barry {
31 // LogLock
33 /// RAII locking class used to protect the logStream passed into
34 /// Barry::Init() (common.h). If the application uses the same stream for
35 /// its own logging, it should use this lock class, or use the macros
36 /// in log.h.
37 ///
38 class BXEXPORT LogLock
40 public:
41 LogLock();
42 ~LogLock();
45 BXEXPORT bool LogVerbose();
46 BXEXPORT std::ostream* GetLogStream();
48 } // namespace Barry
50 #define barrylog(x) { ::Barry::LogLock lock; (*::Barry::GetLogStream()) << x << std::endl; }
52 // controlled by command line -v switch
53 #define barryverbose(x) if(::Barry::LogVerbose()) { ::Barry::LogLock lock; (*::Barry::GetLogStream()) << x << std::endl; }
55 #endif // __BARRY_LOG_H__