~ubuntu-branches/ubuntu/lucid/structure-synth/lucid

« back to all changes in this revision

Viewing changes to SyntopiaCore/Logging/Logging.h

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz
  • Date: 2009-04-13 13:28:45 UTC
  • Revision ID: james.westby@ubuntu.com-20090413132845-d7d42t4llxjxq0ez
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
 
 
3
#include <QString>
 
4
#include <QVector>
 
5
 
 
6
namespace SyntopiaCore {
 
7
        namespace Logging {     
 
8
                /// Predefined logging levels
 
9
                enum LogLevel { NoneLevel, DebugLevel, TimingLevel, InfoLevel, WarningLevel, CriticalLevel, AllLevel };
 
10
 
 
11
                /// Abstract base class for all loggers
 
12
                class Logger {
 
13
                public:
 
14
                        /// The destructors and constructors automatically add to the list of installed loggers.
 
15
                        Logger() { 
 
16
                                loggers.append(this); 
 
17
                        }
 
18
 
 
19
                        virtual ~Logger() { 
 
20
                                // Remove from list of available loggers.
 
21
                                for (int i = loggers.size()-1; i >= 0; i--) {
 
22
                                        if (loggers[i] == this) loggers.remove(i);
 
23
                                }
 
24
                        }
 
25
 
 
26
                        /// This method all loggers must implement
 
27
                        virtual void log(QString message, LogLevel priority) = 0;
 
28
 
 
29
                        /// Log messages are sent to this list of loggers.
 
30
                        static QVector<Logger*> loggers;
 
31
                };
 
32
 
 
33
 
 
34
                void LOG(QString message, LogLevel priority);
 
35
 
 
36
                /// Useful aliases
 
37
                void Debug(QString text);
 
38
                void INFO(QString text);
 
39
                void WARNING(QString text);
 
40
                void CRITICAL(QString text);
 
41
                
 
42
        }
 
43
}
 
44