Projekt

Obecné

Profil

Stáhnout (2.23 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
#include "QsLogDestFunctor.h"
28
#include <cstddef>
29
#include <QtGlobal>
30
31
QsLogging::FunctorDestination::FunctorDestination(LogFunction f)
32
    : QObject(NULL)
33
    , mLogFunction(f)
34
{
35
}
36
37
QsLogging::FunctorDestination::FunctorDestination(QObject *receiver, const char *member)
38
    : QObject(NULL)
39
    , mLogFunction(NULL)
40
{
41
    connect(this, SIGNAL(logMessageReady(QString,int)), receiver, member, Qt::QueuedConnection);
42
}
43
44
45
void QsLogging::FunctorDestination::write(const QString &message, QsLogging::Level level)
46
{
47
    if (mLogFunction)
48
        mLogFunction(message, level);
49
50
    if (level > QsLogging::TraceLevel)
51
        emit logMessageReady(message, static_cast<int>(level));
52
}
53
54
bool QsLogging::FunctorDestination::isValid()
55
{
56
    return true;
57
}