Project

General

Profile

0001-Adding-support-for-syslog.patch

enrico.tagliavini, 06/19/2010 01:22 PM

View differences:

src/common/logger.cpp
25 25
#include <QTextStream>
26 26
#include <QDateTime>
27 27

  
28
#ifndef Q_OS_WIN32
29
#include <QtGlobal>
30
#include <syslog.h>
31
#endif /* Q_OS_WIN32 */
32

  
28 33
Logger::~Logger() {
29 34
  QDateTime date = QDateTime::currentDateTime();
30 35
  if(_logLevel == DebugLevel) _buffer.prepend("Debug: ");
......
44 49
  else lvl = InfoLevel;
45 50

  
46 51
  if(_logLevel < lvl) return;
52
  
53
  #ifndef Q_OS_WIN32
54
  static bool slog = Quassel::isOptionSet("syslog");
55
  if(slog) {
56
    int prio;
57
    switch (lvl) {
58
      case DebugLevel: prio = LOG_DEBUG; break;
59
      case InfoLevel: prio = LOG_INFO; break;
60
      case WarningLevel: prio = LOG_WARNING; break;
61
      case ErrorLevel: prio = LOG_ERR; break;
62
      default: prio = LOG_INFO; break;
63
    }
64
    syslog(LOG_USER & prio, "%s", qPrintable(_buffer));
65
  }
66
  #endif /* Q_OS_WIN32 */
47 67

  
48 68
  // if we can't open logfile we log to stdout
49 69
  QTextStream out(stdout);
src/common/main.cpp
110 110
  cliParser->addSwitch("add-user", 0, "Starts an interactive session to add a new core user");
111 111
  cliParser->addOption("change-userpass <username>", 0, "Starts an interactive session to change the password of the user identified by username");
112 112
#endif
113
#ifndef Q_OS_WIN32
114
  cliParser->addSwitch("syslog", 0, "Send the log to syslog. If used with --logfile the log will be stored in both");
115
#endif /* Q_OS_WIN32 */
113 116

  
114 117
#ifdef HAVE_KDE
115 118
  // the KDE version needs this extra call to parse argc/argv before app is instantiated
116
-