-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimberslide.h
58 lines (44 loc) · 1.56 KB
/
timberslide.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TIMBERSLIDE_TIMBERSLIDE_H_
#define TIMBERSLIDE_TIMBERSLIDE_H_
#include <memory>
#include <string>
#include <utility>
#include <base/files/file_util.h>
#include <base/time/time.h>
#include <brillo/daemons/daemon.h>
#include "timberslide/log_listener.h"
#include "timberslide/string_transformer.h"
namespace timberslide {
class TimberSlide : public brillo::Daemon {
public:
TimberSlide(const std::string& ec_type,
base::File device_file,
base::File uptime_file,
const base::FilePath& log_dir);
std::string ProcessLogBuffer(const std::string& buffer,
const base::Time& now);
protected:
// For testing
explicit TimberSlide(std::unique_ptr<LogListener> log_listener,
std::unique_ptr<StringTransformer> xfrm);
private:
int OnInit() override;
void OnEventReadable();
virtual bool GetEcUptime(int64_t* ec_uptime_ms);
void RotateLogs(const base::FilePath& previous_log,
const base::FilePath& current_log);
base::File device_file_;
base::FilePath current_log_;
base::FilePath previous_log_;
std::unique_ptr<base::FileDescriptorWatcher::Controller> watcher_;
int total_size_ = 0;
base::File uptime_file_;
bool uptime_file_valid_ = false;
std::unique_ptr<LogListener> log_listener_;
std::unique_ptr<StringTransformer> xfrm_;
};
} // namespace timberslide
#endif // TIMBERSLIDE_TIMBERSLIDE_H_