Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/libraries/util/Debug.h @ 6382

Last change on this file since 6382 was 5994, checked in by rgrieder, 15 years ago

Changed Output concept a little bit to allow for more general use.
Every output (log) target has to be implemented as OutputListener. There is already a LogFileWriter and a MemoryLogWriter (stores ALL the log in a vector and provides iterators).
The OutputListener has a unique and constant name, a stream pointer and a soft debug level (that can only be changed via OutputHandler::setSoftDebugLevel(name, level)).
This concept doesn't require the OutputBuffer anymore, so I deleted it.

The adjustments in the Shell are just preliminary for this commit.

  • Property svn:eol-style set to native
File size: 3.2 KB
RevLine 
[1505]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[5991]23 *      Fabian 'x3n' Landau
24 *      Reto Grieder
[1505]25 *   Co-authors:
[5991]26 *      ...
[1505]27 *
28 */
29
30/**
[5991]31@file
32@brief
33    Handles different output-levels of errors, warnings, infos and debug information.
[1791]34
35    The COUT(level) macro acts like std::cout, but the output is only performed if the given
36    level is <= the soft debug level.
37
38    There are two used values in this file:
[5991]39     - The hard debug level is used during compile time. It describes the highest allowed output level.
[1791]40     - The soft debug level is used during runtime and is the maximum of the three configurable
[5991]41       output-levels for console, log file and in game shell.
[1791]42
43    The separation between the three devices is done by the OutputHandler.
44
45    Possible levels are:
46     0: Very important output
47     1: Errors
48     2: Warnings
[5695]49     3: Information
[1791]50     4: Debug information
51     5: More debug information
[5695]52     6: Crazy debug information
[1791]53
[5991]54@example
[1791]55    COUT(0) << "Very important output" << std::endl;
56    COUT(1) << "Error: Something went wrong!" << std::endl;
57    COUT(2) << "Warning: There might be a problem." << std::endl;
[5991]58    COUT(3) << "Info: It's Monday" << std::endl;
[1791]59    COUT(4) << "Debug: x is 1.23456" << std::endl;
[5991]60*/
[1505]61
[5991]62#ifndef _Util_Debug_H__
63#define _Util_Debug_H__
[1505]64
[1586]65#include "UtilPrereqs.h"
[1505]66#include "OutputHandler.h"
67
[2171]68namespace orxonox
[1586]69{
[5991]70    // Just for convenience
71    using std::endl;
[1586]72
[5991]73    //! Adjust to discard certain output with level > hardDebugLevel at compile time
74    const int hardDebugLevel = OutputLevel::Verbose;
[2087]75}
[1586]76
[5991]77/**
[5994]78@brief
[5991]79    Logs text output: use exactly like std::cout, but specify an output
[5994]80    level as argument.
81@example
82    COUT(3) << "Some info" << std::endl;
[5991]83@note
84    The ? : operator requires both possible results to have the type of
85    the first. This is achieved by the int conversion operator dummy
86    in the OutputHandler.
87*/
88#define COUT(level)                                                    \
89    /*if*/ (level > orxonox::hardDebugLevel) ?                         \
90        0                                                              \
91    /*else*/ :                                                         \
92        /*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
93            0                                                          \
94        /*else*/ :                                                     \
95            orxonox::OutputHandler::getOutStream(level)
[1505]96
[5991]97#endif /* _Util_Debug_H__ */
Note: See TracBrowser for help on using the repository browser.