47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <optional>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
enum class Buffer {
|
|
Unknown = 0b1,
|
|
Main = 0b10,
|
|
System = 0b100,
|
|
Radio = 0b1000,
|
|
Events = 0b10000,
|
|
Crash = 0b100000,
|
|
};
|
|
|
|
enum class Priority {
|
|
Unknown = 0b1,
|
|
Verbose = 0b10,
|
|
Debug = 0b100,
|
|
Info = 0b1000,
|
|
Warn = 0b10000,
|
|
Error = 0b100000,
|
|
Fatal = 0b1000000,
|
|
};
|
|
|
|
struct LogcatEntry {
|
|
Buffer buffer;
|
|
time_t time;
|
|
std::optional<std::string> user;
|
|
size_t pid;
|
|
size_t tid;
|
|
Priority priority;
|
|
std::string tag;
|
|
std::string message;
|
|
};
|
|
|
|
const char* to_string(Priority priority);
|
|
const char* to_string(Buffer buffer);
|
|
std::string to_string(const LogcatEntry& logcat_entry);
|
|
std::optional<LogcatEntry> try_parse_logcat_entry(char* buf, size_t length, Buffer buffer);
|
|
std::optional<Buffer> try_parse_buffer(char* buf, size_t length);
|
|
|
|
void from_json(const nlohmann::json& j, Buffer& buffer);
|
|
void to_json(nlohmann::json& j, const Buffer& buffer);
|
|
void from_json(const nlohmann::json& j, Priority& priority);
|
|
void to_json(nlohmann::json& j, const Priority& priority);
|