blob: 9fa6503c42284d161538d7fe7832627ce1f67385 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_DEVELOPER_FEEDBACK_REBOOT_INFO_REBOOT_LOG_H_
#define SRC_DEVELOPER_FEEDBACK_REBOOT_INFO_REBOOT_LOG_H_
#include <lib/zx/time.h>
#include <optional>
#include <string>
#include "src/developer/feedback/reboot_info/reboot_reason.h"
namespace feedback {
// Wrapper around a device's reboot log.
class RebootLog {
public:
static RebootLog ParseRebootLog(const std::string& path);
bool HasRebootLogStr() const { return reboot_log_str_.has_value(); }
bool HasUptime() const { return last_boot_uptime_.has_value(); }
std::string RebootLogStr() const { return reboot_log_str_.value(); }
enum RebootReason RebootReason() const { return reboot_reason_; }
zx::duration Uptime() const { return last_boot_uptime_.value(); }
// Exposed for testing purposes.
RebootLog(enum RebootReason reboot_reason, std::optional<std::string> reboot_log_str,
std::optional<zx::duration> last_boot_uptime);
private:
enum RebootReason reboot_reason_;
std::optional<std::string> reboot_log_str_;
std::optional<zx::duration> last_boot_uptime_;
};
} // namespace feedback
#endif // SRC_DEVELOPER_FEEDBACK_REBOOT_INFO_REBOOT_LOG_H_