LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
QsLogDest.h
Go to the documentation of this file.
1// Copyright (c) 2010, Razvan Petru
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6// Redistribution and use in source and binary forms, with or without modification,
7// are permitted provided that the following conditions are met:
8
9// * Redistributions of source code must retain the above copyright notice, this
10// list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright notice, this
12// list of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14// * The name of the contributors may not be used to endorse or promote products
15// derived from this software without specific prior written permission.
16
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26// OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef QSLOGDEST_H
29#define QSLOGDEST_H
30
31#include <memory>
32#include <QtCore/QString>
33#include <QtCore/QObject>
34
35
36#include "QsLog_export.h"
37
38
39namespace QsLogging
40{
41
43{
44public:
45 virtual ~Destination() = default;
46 virtual void write(const QString& message, const QString& zone) = 0;
47};
48
49typedef std::shared_ptr<Destination> DestinationPtr;
50
51class DestinationsImpl; // d pointer
53{
54Q_OBJECT
55 friend class DestinationsImpl;
56public:
58 {
59 static Destinations staticDestinations;
60 return staticDestinations;
61 }
62
63 bool setDefault();
64 bool removeDefault();
65 bool configure(const QString& fileName, bool reload = false);
66
67 const QMap< QString, DestinationPtr >& destinations() const;
68
69private Q_SLOTS:
70 void configureFileChanged ( const QString & path );
71
72private:
73 Destinations(QObject* parent = 0);
75 virtual ~Destinations();
76 Destinations& operator=(const Destinations&);
77
79};
80
84{
85public:
86 static DestinationPtr MakeFileDestination(const QString& filePath);
87 static DestinationPtr MakeDebugOutputDestination();
88};
89
92{
93public:
94 virtual void write(const QString& message, const QString& zone = QLatin1String("")) override;
95};
96
97
98} // end namespace
99
100#endif // QSLOGDEST_H
#define LIMA_COMMONQSLOG_EXPORT
Creates logging destinations/sinks.
Definition QsLogDest.h:84
virtual void write(const QString &message, const QString &zone)=0
virtual ~Destination()=default
static Destinations & instance()
Definition QsLogDest.h:57
std::shared_ptr< Destination > DestinationPtr
Definition QsLog.cpp:47