# log.h

Go to the documentation of this file.

    00001 ///
    00002 /// \file       log.h
    00003 ///             General header for the Barry library
    00004 ///
    00005
    00006 /*
    00007     Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/)
    00008
    00009     This program is free software; you can redistribute it and/or modify
    00010     it under the terms of the GNU General Public License as published by
    00011     the Free Software Foundation; either version 2 of the License, or
    00012     (at your option) any later version.
    00013
    00014     This program is distributed in the hope that it will be useful,
    00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00017
    00018     See the GNU General Public License in the COPYING file at the
    00019     root directory of this project for more details.
    00020 */
    00021
    00022 #ifndef __BARRY_LOG_H__
    00023 #define __BARRY_LOG_H__
    00024
    00025 #include "dll.h"
    00026 #include <iomanip>
    00027
    00028 namespace Barry {
    00029
    00030 //
    00031 // LogLock
    00032 //
    00033 /// RAII locking class used to protect the logStream passed into
    00034 /// Barry::Init() (common.h).  If the application uses the same stream for
    00035 /// its own logging, it should use this lock class, or use the macros
    00036 /// in log.h.
    00037 ///
    00038 class BXEXPORT LogLock
    00039 {
    00040 public:
    00041         LogLock();
    00042         ~LogLock();
    00043 };
    00044
    00045 BXEXPORT bool LogVerbose();
    00046 BXEXPORT std::ostream* GetLogStream();
    00047
    00048 } // namespace Barry
    00049
    00050 #define barrylog(x)     { ::Barry::LogLock lock; (*::Barry::GetLogStream()) << x << std::endl; }
    00051
    00052 // controlled by command line -v switch
    00053 #define barryverbose(x) if(::Barry::LogVerbose()) { ::Barry::LogLock lock; (*::Barry::GetLogStream()) << x << std::endl; }
    00054
    00055 #endif // __BARRY_LOG_H__
    00056