~ubuntu-branches/ubuntu/jaunty/quassel/jaunty-backports

« back to all changes in this revision

Viewing changes to src/common/logger.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-11-17 15:22:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081117152246-3lwlpnr4r08910kv
Tags: 0.3.1-0ubuntu1
* New upstream release (LP: #271403)
* Drop all patches originated from upstream (quassel_*)
* Compile with non-builtin quassel icons
  + Introduce new quassel-data package
  + quassel and quassel-client depend on quassel-data
  + Don't manually enforce icon installation for desktop files in debian/rules
  + Add quassel_01_fix_iconloader.patch
* Drop perl build dependency, I have no clue why it was added in the first
  place. Neither changelog nor Bazaar knows, and since quassel compiles just
  fine without it, removing it should be save.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 ***************************************************************************/
20
20
 
21
21
#include "logger.h"
22
 
#include "global.h"
 
22
#include "quassel.h"
23
23
 
24
24
#include <QFile>
25
25
#include <QTextStream>
37
37
 
38
38
void Logger::log() {
39
39
  LogLevel lvl;
40
 
  if (Global::parser.value("loglevel") == "Debug") lvl = DebugLevel;
41
 
  else if (Global::parser.value("loglevel") == "Info") lvl = InfoLevel;
42
 
  else if (Global::parser.value("loglevel") == "Warning") lvl = WarningLevel;
43
 
  else if (Global::parser.value("loglevel") == "Error") lvl = ErrorLevel;
 
40
  if (Quassel::optionValue("loglevel") == "Debug") lvl = DebugLevel;
 
41
  else if (Quassel::optionValue("loglevel") == "Info") lvl = InfoLevel;
 
42
  else if (Quassel::optionValue("loglevel") == "Warning") lvl = WarningLevel;
 
43
  else if (Quassel::optionValue("loglevel") == "Error") lvl = ErrorLevel;
44
44
  else lvl = InfoLevel;
45
45
 
46
46
  if(_logLevel < lvl) return;
48
48
  // if we can't open logfile we log to stdout
49
49
  QTextStream out(stdout);
50
50
  QFile file;
51
 
  if(!Global::parser.value("logfile").isEmpty()) {
52
 
    file.setFileName(Global::parser.value("logfile"));
 
51
  if(!Quassel::optionValue("logfile").isEmpty()) {
 
52
    file.setFileName(Quassel::optionValue("logfile"));
53
53
    if (file.open(QIODevice::Append | QIODevice::Text)) {
54
54
      out.setDevice(&file);
55
55
      _buffer.remove(QChar('\n'));
58
58
  out << _buffer << endl;
59
59
  if(file.isOpen()) file.close();
60
60
}
 
61
 
 
62
 
 
63
void Logger::logMessage(QtMsgType type, const char *msg) {
 
64
  switch (type) {
 
65
  case QtDebugMsg:
 
66
    Logger(Logger::DebugLevel) << msg;
 
67
    break;
 
68
  case QtWarningMsg:
 
69
    Logger(Logger::WarningLevel) << msg;
 
70
    break;
 
71
  case QtCriticalMsg:
 
72
    Logger(Logger::ErrorLevel) << msg;
 
73
    break;
 
74
  case QtFatalMsg:
 
75
    Logger(Logger::ErrorLevel) << msg;
 
76
    Quassel::logFatalMessage(msg);
 
77
    return;
 
78
  }
 
79
}