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#include <cstdint>
25
26#include "log/loggerConfiguration.hpp"
27#include "log/logger.hpp"
28#include "log/writer.hpp"
29
30#include "singleton.hpp"
31
32#include "conf/configuration.hpp"
33#include "conf/section.hpp"
34
35
36namespace anch::log {
37
47 class LoggerFactory: public anch::Singleton<LoggerFactory> {
48 friend class anch::Singleton<LoggerFactory>;
49
50 private:
51 // Attributes +
53 std::map<std::string, anch::log::LoggerConfiguration> _loggersConfig;
54
56 std::map<std::string, anch::log::Logger*> _loggers;
57 // Attributes -
58
59 private:
60 // Constructor +
64 LoggerFactory();
65 // Constructor -
66
67 private:
68 // Destructor +
73 virtual ~LoggerFactory();
74 // Destructor -
75
76 public:
77 // Methods +
86 static const anch::log::Logger& getLogger(const std::string& loggerName);
87
88 private:
95 void initializeWriters(std::map<std::string, anch::log::Writer*>& writers, const anch::conf::Section* conf);
96
102 void createDefaultLogger(const std::map<std::string, anch::log::Writer*>& writers);
103
110 void initializeLoggers(const std::map<std::string, anch::log::Writer*>& writers, const anch::conf::Section* conf);
111
115 void loadDefaultConfiguration();
116 // Methods -
117
118 };
119
120}
Meyers' singleton implementation.
Definition singleton.hpp:34
static const anch::log::Logger & getLogger(const std::string &loggerName)
Definition logger.hpp:45