logmeow/logcat_entry.h

41 lines
722 B
C++

#pragma once
#include <string>
#include <optional>
enum class Buffer {
Unknown,
Main,
System,
Radio,
Events,
Crash,
};
enum class Priority {
Unknown,
Verbose,
Debug,
Info,
Warn,
Error,
Fatal,
};
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);
std::optional<Buffer> try_parse_buffer(char* buf, size_t length);