/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. #ifndef TOMAHAWK_LOGGER_H
  19. #define TOMAHAWK_LOGGER_H
  20. #include <QDebug>
  21. #include <QFile>
  22. #include "DllMacro.h"
  23. #include "config.h"
  24. #define LOGDEBUG 1
  25. #define LOGINFO 2
  26. #define LOGEXTRA 5
  27. #define LOGVERBOSE 8
  28. #define LOGTHIRDPARTY 9
  29. #define LOGSQL 10
  30. namespace Logger
  31. {
  32. class DLLEXPORT TLog : public QDebug
  33. {
  34. public:
  35. TLog( unsigned int debugLevel = 0 );
  36. virtual ~TLog();
  37. private:
  38. QString m_msg;
  39. unsigned int m_debugLevel;
  40. };
  41. class DLLEXPORT TDebug : public TLog
  42. {
  43. public:
  44. TDebug( unsigned int debugLevel = LOGDEBUG ) : TLog( debugLevel )
  45. {
  46. }
  47. };
  48. class DLLEXPORT TSqlLog : public TLog
  49. {
  50. public:
  51. TSqlLog() : TLog( LOGSQL )
  52. {
  53. }
  54. };
  55. DLLEXPORT void TomahawkLogHandler( QtMsgType type, const char* msg );
  56. DLLEXPORT void setupLogfile( QFile& f );
  57. }
  58. #define tLog Logger::TLog
  59. #define tDebug Logger::TDebug
  60. #define tSqlLog Logger::TSqlLog
  61. DLLEXPORT void tLogNotifyShutdown();
  62. // Macro for messages that severely hurt performance but are helpful
  63. // in some cases for better debugging.
  64. #ifdef TOMAHAWK_FINEGRAINED_MESSAGES
  65. #define FINEGRAINED_MSG(a) tDebug( LOGVERBOSE ) << a ;
  66. #else
  67. #define FINEGRAINED_MSG(a)
  68. #endif
  69. #endif // TOMAHAWK_LOGGER_H