logmeow/logcat_entry.h

41 lines
836 B
C
Raw Normal View History

2023-01-19 16:34:03 +00:00
#pragma once
#include <string>
#include <optional>
enum class Buffer {
2023-01-23 09:10:01 +00:00
Unknown = 0b1,
Main = 0b10,
System = 0b100,
Radio = 0b1000,
Events = 0b10000,
Crash = 0b100000,
2023-01-19 16:34:03 +00:00
};
enum class Priority {
2023-01-23 09:10:01 +00:00
Unknown = 0b1,
Verbose = 0b10,
Debug = 0b100,
Info = 0b1000,
Warn = 0b10000,
Error = 0b100000,
Fatal = 0b1000000,
2023-01-19 16:34:03 +00:00
};
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;
};
Priority priority_from(char c);
const char* priority_to(Priority priority);
const char* buffer_to(Buffer buffer);
std::optional<LogcatEntry> try_parse_logcat_entry(char* buf, size_t length, Buffer buffer);
2023-01-20 14:41:06 +00:00
std::optional<Buffer> try_parse_buffer(char* buf, size_t length);