libIntegra
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
trace.h
Go to the documentation of this file.
1  /* libIntegra modular audio framework
2  *
3  * Copyright (C) 2007 Birmingham City University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18  * USA.
19  */
20 
34 #ifndef INTEGRA_TRACING_PRIVATE
35 #define INTEGRA_TRACING_PRIVATE
36 
37 #include "common_typedefs.h"
38 #include <ostream>
39 #include <fstream>
40 
41 
43 #define STRINGIFY(x) #x
44 
45 #define TOSTRING(x) STRINGIFY(x)
46 #ifdef _WINDOWS
47 
48 #define INTEGRA_FUNCTION __FUNCTION__
49 #else
50 
51 #define INTEGRA_FUNCTION TOSTRING(__FUNCTION__)
52 #endif /*_WINDOWS*/
53 
55 #define INTEGRA_LOCATION __FILE__ ": " TOSTRING(__LINE__) "(" INTEGRA_FUNCTION ")"
56 
57 
58 
59 
66 #define INTEGRA_TRACE_ERROR integra_api::CTrace::error( INTEGRA_LOCATION )
67 
74 #define INTEGRA_TRACE_PROGRESS integra_api::CTrace::progress( INTEGRA_LOCATION )
75 
86 #define INTEGRA_TRACE_VERBOSE integra_api::CTrace::verbose( INTEGRA_LOCATION )
87 
88 
89 
90 namespace integra_api
91 {
105  class INTEGRA_API CTrace
106  {
107  public:
108 
113  static void set_categories_to_trace( bool errors, bool progress, bool verbose );
114 
123  static void set_details_to_trace( bool timestamp, bool location, bool thread );
124 
126  static std::ostream &error( const char *location );
127 
129  static std::ostream &progress( const char *location );
130 
132  static std::ostream &verbose( const char *location );
133 
134  private:
135 
136  static void do_trace( const char *category, const char *location );
137 
138  static bool s_trace_errors;
139  static bool s_trace_progress;
140  static bool s_trace_verbose;
141 
142  static bool s_trace_timestamp;
143  static bool s_trace_location;
144  static bool s_trace_thread;
145 
146  static std::ostream &s_trace_stream;
147  static std::ofstream s_null_stream;
148 
149  static const int max_timestamp_length;
150  };
151 }
152 
153 
154 #endif /*INTEGRA_TRACING_PRIVATE*/
Handles console output.
Definition: trace.h:105
#defines and typedefs used throughout the application