Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
simple-logger.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef IMPALA_SERVICE_SIMPLE_LOGGER_H
16 #define IMPALA_SERVICE_SIMPLE_LOGGER_H
17 
18 #include <boost/thread/thread.hpp>
19 #include <fstream>
20 
21 #include "common/status.h"
22 
23 namespace impala {
24 
28 class SimpleLogger {
29  public:
30  SimpleLogger(const std::string& log_dir_, const std::string& log_file_name_prefix_,
31  uint64_t max_entries_per_file);
32 
36  Status Init();
37 
41  Status AppendEntry(const std::string& entry);
42 
45  Status Flush();
46 
47  private:
49  boost::mutex log_file_lock_;
50 
52  std::string log_dir_;
53 
55  std::string log_file_name_prefix_;
56 
60 
64 
66  std::ofstream log_file_;
67 
69  std::string log_file_name_;
70 
73  void GenerateLogFileName();
74 
78 };
79 }
80 #endif
std::ofstream log_file_
Log files are written to this stream.
Definition: simple-logger.h:66
boost::mutex log_file_lock_
Protects log_file_, num_log_file_entries_ and log_file_name_.
Definition: simple-logger.h:49
std::string log_file_name_
Current log file name.
Definition: simple-logger.h:69
uint64_t num_log_file_entries_
Definition: simple-logger.h:59
Status AppendEntry(const std::string &entry)
std::string log_dir_
Directory to log to.
Definition: simple-logger.h:52
SimpleLogger(const std::string &log_dir_, const std::string &log_file_name_prefix_, uint64_t max_entries_per_file)
std::string log_file_name_prefix_
Prefix for all log files.
Definition: simple-logger.h:55
uint64_t max_entries_per_file_
Definition: simple-logger.h:63