Projekt

Obecné

Profil

Stáhnout (2.8 KB) Statistiky
| Větev: | Tag: | Revize:
1
// Copyright (c) 2013, Razvan Petru
2
// All rights reserved.
3

    
4
// Redistribution and use in source and binary forms, with or without modification,
5
// are permitted provided that the following conditions are met:
6

    
7
// * Redistributions of source code must retain the above copyright notice, this
8
//   list of conditions and the following disclaimer.
9
// * Redistributions in binary form must reproduce the above copyright notice, this
10
//   list of conditions and the following disclaimer in the documentation and/or other
11
//   materials provided with the distribution.
12
// * The name of the contributors may not be used to endorse or promote products
13
//   derived from this software without specific prior written permission.
14

    
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
24
// OF THE POSSIBILITY OF SUCH DAMAGE.
25

    
26
#include "QsLogDest.h"
27
#include "QsLogDestConsole.h"
28
#include "QsLogDestFile.h"
29
#include "QsLogDestFunctor.h"
30
#include <QString>
31

    
32
namespace QsLogging
33
{
34

    
35
Destination::~Destination()
36
{
37
}
38

    
39
//! destination factory
40
DestinationPtr DestinationFactory::MakeFileDestination(const QString& filePath,
41
    LogRotationOption rotation, const MaxSizeBytes &sizeInBytesToRotateAfter,
42
    const MaxOldLogCount &oldLogsToKeep)
43
{
44
    if (EnableLogRotation == rotation) {
45
        QScopedPointer<SizeRotationStrategy> logRotation(new SizeRotationStrategy);
46
        logRotation->setMaximumSizeInBytes(sizeInBytesToRotateAfter.size);
47
        logRotation->setBackupCount(oldLogsToKeep.count);
48

    
49
        return DestinationPtr(new FileDestination(filePath, RotationStrategyPtr(logRotation.take())));
50
    }
51

    
52
    return DestinationPtr(new FileDestination(filePath, RotationStrategyPtr(new NullRotationStrategy)));
53
}
54

    
55
DestinationPtr DestinationFactory::MakeDebugOutputDestination()
56
{
57
    return DestinationPtr(new DebugOutputDestination);
58
}
59

    
60
DestinationPtr DestinationFactory::MakeFunctorDestination(QsLogging::Destination::LogFunction f)
61
{
62
    return DestinationPtr(new FunctorDestination(f));
63
}
64

    
65
DestinationPtr DestinationFactory::MakeFunctorDestination(QObject *receiver, const char *member)
66
{
67
    return DestinationPtr(new FunctorDestination(receiver, member));
68
}
69

    
70
} // end namespace
(7-7/19)