PageRenderTime 102ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 57ms app.codeStats 0ms

/src/libtomahawk/utils/Logger.h

http://github.com/tomahawk-player/tomahawk
C Header | 81 lines | 50 code | 12 blank | 19 comment | 0 complexity | 37326135a062f1ef532bb4567171a3be MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 5 *   Tomahawk 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 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef TOMAHAWK_LOGGER_H
20#define TOMAHAWK_LOGGER_H
21
22#include <QDebug>
23#include <QFile>
24
25#include "DllMacro.h"
26#include "config.h"
27
28#define LOGDEBUG 1
29#define LOGINFO 2
30#define LOGEXTRA 5
31#define LOGVERBOSE 8
32#define LOGTHIRDPARTY 9
33#define LOGSQL 10
34
35namespace Logger
36{
37    class DLLEXPORT TLog : public QDebug
38    {
39    public:
40        TLog( unsigned int debugLevel = 0 );
41        virtual ~TLog();
42
43    private:
44        QString m_msg;
45        unsigned int m_debugLevel;
46    };
47
48    class DLLEXPORT TDebug : public TLog
49    {
50    public:
51        TDebug( unsigned int debugLevel = LOGDEBUG ) : TLog( debugLevel )
52        {
53        }
54    };
55
56    class DLLEXPORT TSqlLog : public TLog
57    {
58    public:
59        TSqlLog() : TLog( LOGSQL )
60        {
61        }
62    };
63
64    DLLEXPORT void TomahawkLogHandler( QtMsgType type, const char* msg );
65    DLLEXPORT void setupLogfile( QFile& f );
66}
67
68#define tLog Logger::TLog
69#define tDebug Logger::TDebug
70#define tSqlLog Logger::TSqlLog
71DLLEXPORT void tLogNotifyShutdown();
72
73// Macro for messages that severely hurt performance but are helpful
74// in some cases for better debugging.
75#ifdef TOMAHAWK_FINEGRAINED_MESSAGES
76    #define FINEGRAINED_MSG(a) tDebug( LOGVERBOSE ) << a ;
77#else
78    #define FINEGRAINED_MSG(a)
79#endif
80
81#endif // TOMAHAWK_LOGGER_H