Projekt

Obecné

Profil

Stáhnout (2.51 KB) Statistiky
| Větev: | Tag: | Revize:
1 c137512e Oto Šťáva
// Copyright (c) 2014, Razvan Petru
2
// Copyright (c) 2014, Omar Carey
3
// All rights reserved.
4
5
// Redistribution and use in source and binary forms, with or without modification,
6
// are permitted provided that the following conditions are met:
7
8
// * Redistributions of source code must retain the above copyright notice, this
9
//   list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright notice, this
11
//   list of conditions and the following disclaimer in the documentation and/or other
12
//   materials provided with the distribution.
13
// * The name of the contributors may not be used to endorse or promote products
14
//   derived from this software without specific prior written permission.
15
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
// OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#ifndef QSLOGDESTFUNCTOR_H
28
#define QSLOGDESTFUNCTOR_H
29
30
#include "QsLogDest.h"
31
#include <QObject>
32
33
namespace QsLogging
34
{
35
// Offers various types of function-like sinks.
36
// This is an advanced destination type. Depending on your configuration, LogFunction might be
37
// called from a different thread or even a different binary. You should not access QsLog from
38
// inside LogFunction and should not perform any time-consuming operations.
39
// logMessageReady is connected through a queued connection and trace messages are not included
40
class FunctorDestination : public QObject, public Destination
41
{
42
    Q_OBJECT
43
public:
44
    explicit FunctorDestination(LogFunction f);
45
    FunctorDestination(QObject *receiver, const char *member);
46
47
    virtual void write(const QString &message, Level level);
48
    virtual bool isValid();
49
50
protected:
51
    // int used to avoid registering a new enum type
52
    Q_SIGNAL void logMessageReady(const QString &message, int level);
53
54
private:
55
    LogFunction mLogFunction;
56
};
57
}
58
59
#endif // QSLOGDESTFUNCTOR_H