AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
threadSafeWriter.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_THREAD_SAFE_WRITER_H_
21 #define _ANCH_LOGGER_THREAD_SAFE_WRITER_H_
22 
23 #include <mutex>
24 
25 #include "logger/writer.hpp"
26 
27 
28 namespace anch {
29  namespace logger {
30 
36  class ThreadSafeWriter: public Writer {
37  private:
38  // Attributes +
40  std::mutex _mutex;
41  // Attributes -
42 
43  public:
44  // Constructors +
53  ThreadSafeWriter(const std::string& fileName,
54  const std::string& linePattern,
55  int maxSize = 0,
56  int maxIndex = 0);
57 
64  ThreadSafeWriter(std::ostream* output, const std::string& linePattern);
65  // Constructors -
66 
67  // Destructor +
71  virtual ~ThreadSafeWriter();
72  // Destructor -
73 
74  public:
82  virtual void write(const std::string& category,
83  const anch::logger::Level& level,
84  const std::string& message);
85 
86  };
87 
88  }
89 }
90 
91 #endif // _ANCH_LOGGER_THREAD_SAFE_WRITER_H_
virtual void write(const std::string &category, const anch::logger::Level &level, const std::string &message)
Definition: threadSafeWriter.cpp:74
AnCH framework base namespace.
Definition: base64.hpp:28
ThreadSafeWriter(const std::string &fileName, const std::string &linePattern, int maxSize=0, int maxIndex=0)
Definition: threadSafeWriter.cpp:39
virtual ~ThreadSafeWriter()
Definition: threadSafeWriter.cpp:62
Definition: threadSafeWriter.hpp:36
Level
Definition: levels.hpp:34
Definition: writer.hpp:37