File: Logging.h

package info (click to toggle)
structure-synth 1.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,072 kB
  • ctags: 1,176
  • sloc: cpp: 7,070; python: 167; makefile: 66; lisp: 25
file content (44 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <QString>
#include <QVector>

namespace SyntopiaCore {
	namespace Logging {	
		/// Predefined logging levels
		enum LogLevel { NoneLevel, DebugLevel, TimingLevel, InfoLevel, WarningLevel, CriticalLevel, AllLevel };

		/// Abstract base class for all loggers
		class Logger {
		public:
			/// The destructors and constructors automatically add to the list of installed loggers.
			Logger() { 
				loggers.append(this); 
			}

			virtual ~Logger() { 
				// Remove from list of available loggers.
				for (int i = loggers.size()-1; i >= 0; i--) {
					if (loggers[i] == this) loggers.remove(i);
				}
			}

			/// This method all loggers must implement
			virtual void log(QString message, LogLevel priority) = 0;

			/// Log messages are sent to this list of loggers.
			static QVector<Logger*> loggers;
		};


		void LOG(QString message, LogLevel priority);

		/// Useful aliases
		void Debug(QString text);
		void INFO(QString text);
		void WARNING(QString text);
		void CRITICAL(QString text);
		
	}
}