0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Cronolog.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Common_Cronolog_h
28 #define Common_Cronolog_h
29 
30 #include <ctime>
31 #include <mutex>
32 #include <string>
33 
34 namespace Hypertable {
35 
36  using namespace std;
37 
40 
59  class Cronolog {
60 
61  public:
62 
67  Cronolog(const string &name, const string &current_dir, const string &archive_dir);
68 
71  virtual ~Cronolog();
72 
84  void write(time_t now, const string &line);
85 
88  void sync();
89 
90  private:
91 
102  void roll(time_t now);
103 
106 
108  string m_name;
109 
112 
115 
117  time_t m_roll_time;
118 
120  int m_fd {};
121 
122  };
123 
125 }
126 
127 #endif // Common_Cronolog_h
static std::mutex mutex
Definition: Logger.cc:43
string m_name
Basename of log file.
Definition: Cronolog.h:108
string m_current_dir
Directory containing current symlink of log file.
Definition: Cronolog.h:111
STL namespace.
mutex m_mutex
Mutex for serializing access to member variables
Definition: Cronolog.h:105
Time based rotating log.
Definition: Cronolog.h:59
Hypertable definitions
string m_archive_dir
Directory containing log archives.
Definition: Cronolog.h:114
time_t m_roll_time
Time (seconds since Epoch) when next roll is required.
Definition: Cronolog.h:117