Receptacle
 All Classes Files Functions Variables Pages
log_emitter.h
1 /*
2 
3 Copyright 2014 William Wedler
4 
5 This file is part of Receptacle
6 
7 Receptacle is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Receptacle is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Receptacle. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 
23 // log_emitter.h
24 
25 #ifndef LOG_EMITTER_H
26 #define LOG_EMITTER_H
27 
28 #include <QObject>
29 #include <QString>
30 #include <QDebug>
31 #include <QCoreApplication>
32 
33 // Includes for reading user name
34 #if defined(Q_OS_WIN)
35 #include <stdlib.h>
36 #else //LINUX
37 #include <pwd.h>
38 #include <unistd.h>
39 #endif
40 
41 class LogEmitter : public QObject
42 {
43  Q_OBJECT
44 public:
45  LogEmitter();
46  ~LogEmitter();
47  void publish_message(QtMsgType type, const QMessageLogContext &context, const QString &msg);
48 
53  static QString username();
54 
55 signals:
56  void info_message(const QString &msg);
57  void warn_message(const QString &msg);
58  void critical_message(const QString &msg);
59  void fatal_message(const QString &msg);
60 
61 protected:
62  const QString detailed_msg(const QMessageLogContext &context, const QString &msg);
63 };
64 
65 #endif // LOG_EMITTER_H
Definition: log_emitter.h:41
static QString username()
username
Definition: log_emitter.cpp:58