AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
lowPriorityWriter.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 #ifndef _ANCH_LOGGER_LOW_PRIORITY_WRITER_H_
21 #define _ANCH_LOGGER_LOW_PRIORITY_WRITER_H_
22 
23 #include <iostream>
24 #include <queue>
25 #include <mutex>
26 #include <thread>
27 
28 #include "logger/writer.hpp"
29 
30 
31 namespace anch {
32  namespace logger {
33 
40  class LowPriorityWriter: public Writer {
41 
42  // Attributes +
43  private:
45  std::queue<std::string> _messages;
46 
48  bool _running;
49 
51  std::thread* _thread;
52 
54  std::mutex _mutex;
55  // Attributes -
56 
57  public:
58  // Constructors +
67  LowPriorityWriter(const std::string& fileName,
68  const std::string& linePattern,
69  int maxSize = 0,
70  int maxIndex = 0);
71 
78  LowPriorityWriter(std::ostream* output, const std::string& linePattern);
79  // Constructors -
80 
81  // Destructor +
85  virtual ~LowPriorityWriter();
86  // Destructor -
87 
88 
89  // Method +
90  public:
98  virtual void write(const std::string& category,
99  const anch::logger::Level& level,
100  const std::string& message);
101 
105  void startTreatment();
106 
107  private:
111  void process();
112  // Method -
113 
114  };
115 
116  }
117 }
118 
119 #endif // _ANCH_LOGGER_LOW_PRIORITY_WRITER_H_
void startTreatment()
Definition: lowPriorityWriter.cpp:127
virtual ~LowPriorityWriter()
Definition: lowPriorityWriter.cpp:72
virtual void write(const std::string &category, const anch::logger::Level &level, const std::string &message)
Definition: lowPriorityWriter.cpp:88
AnCH framework base namespace.
Definition: base64.hpp:28
Definition: lowPriorityWriter.hpp:40
LowPriorityWriter(const std::string &fileName, const std::string &linePattern, int maxSize=0, int maxIndex=0)
Definition: lowPriorityWriter.cpp:44
Level
Definition: levels.hpp:34
Definition: writer.hpp:37