AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
loggerFactory.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework 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 ANCH Framework 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 ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <map>
23#include <vector>
24
25#include "logger/loggerConfiguration.hpp"
26#include "logger/logger.hpp"
27#include "logger/writer.hpp"
28#include "resource/resource.hpp"
29#include "singleton.hpp"
30
31
32namespace anch::logger {
33
43 class LoggerFactory: public anch::Singleton<LoggerFactory> {
44 friend class anch::Singleton<LoggerFactory>;
45
46 public:
48 static std::string CONF_FILE;
49
50 private:
51 // Attributes +
53 std::vector<anch::logger::LoggerConfiguration> _loggersConfig;
54
56 std::vector<anch::logger::Logger*> _loggers;
57 // Attributes -
58
59 private:
60 // Constructor +
64 LoggerFactory();
65 // Constructor -
66
67 // Destructor +
72 virtual ~LoggerFactory();
73 // Destructor -
74
75 public:
76 // Methods +
85 static const anch::logger::Logger& getLogger(const std::string& loggerName);
86
87 private:
96 anch::logger::Writer* createWriterInstance(bool threadSafe, bool lowPriority, std::ostream* out, const std::string& pattern);
97
108 anch::logger::Writer* createWriterInstance(bool threadSafe, bool lowPriority, const std::string& path, const std::string& pattern, uint32_t maxSize, int maxIndex);
109
116 void initializeWriters(std::map<std::string,anch::logger::Writer*>& writers, const anch::resource::Resource& resource);
117
124 void initializeLoggersConfiguration(const std::map<std::string,anch::logger::Writer*>& writers, const anch::resource::Resource& resource);
125
129 void loadDefaultConfiguration();
130 // Methods -
131
132 };
133
134}
Meyers' singleton implementation.
Definition singleton.hpp:34
static const anch::logger::Logger & getLogger(const std::string &loggerName)
static std::string CONF_FILE
Definition loggerFactory.hpp:48
Definition logger.hpp:45
Definition writer.hpp:35
Definition resource.hpp:35
Logger namespace.
Definition anchDateFormatter.hpp:27
Resources namespace.
Definition configurationFileParser.hpp:28