Save recent Widevine CDM logs

Bug: 162255728
Test: cdm unit tests
Change-Id: Ibc0daf374bedd8ac2a9a0515835e2775045962a7
This commit is contained in:
Robert Shih
2021-02-03 08:10:40 -08:00
parent 2b094e710e
commit 83ef9081d1
2 changed files with 53 additions and 0 deletions

View File

@@ -7,6 +7,11 @@
#ifndef WVCDM_UTIL_LOG_H_
#define WVCDM_UTIL_LOG_H_
#include <cstdint>
#include <deque>
#include <mutex>
#include <string>
#include <vector>
#include "util_common.h"
namespace wvcdm {
@@ -27,6 +32,24 @@ typedef enum {
extern LogPriority g_cutoff;
struct LogMessage {
int64_t time_ms_;
LogPriority priority_;
std::string message_;
};
class LogBuffer {
public:
static const int MAX_CAPACITY = 100;
void addLog(const LogMessage& log);
std::vector<LogMessage> getLogs();
private:
std::deque<LogMessage> buffer_;
std::mutex mutex_;
};
extern LogBuffer g_logbuf;
// Enable/disable verbose logging (LOGV).
// This function is supplied for cases where the system layer does not
// initialize logging. This is also needed to initialize logging in