Initial v17 Release
Headers and Unit tests have been updated to match the v17 spec. Documentation can be found here: https://developers.devsite.corp.google.com/widevine/drm/client/oemcrypto/v17
This commit is contained in:
@@ -7,9 +7,15 @@
|
||||
#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 {
|
||||
namespace wvutil {
|
||||
|
||||
// Simple logging class. The implementation is platform dependent.
|
||||
|
||||
@@ -27,15 +33,53 @@ typedef enum {
|
||||
|
||||
extern LogPriority g_cutoff;
|
||||
|
||||
struct LogMessage {
|
||||
uint32_t uid_;
|
||||
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;
|
||||
|
||||
static const uint32_t UNKNOWN_UID = ~0;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
void SetLoggingUid(const uint32_t);
|
||||
void ClearLoggingUid();
|
||||
uint32_t GetLoggingUid();
|
||||
uint32_t GetIpcCallingUid();
|
||||
#else
|
||||
static inline void SetLoggingUid(const uint32_t) {}
|
||||
static inline void ClearLoggingUid() {}
|
||||
static inline uint32_t GetLoggingUid() { return UNKNOWN_UID; }
|
||||
static inline uint32_t GetIpcCallingUid() { return UNKNOWN_UID; }
|
||||
#endif
|
||||
|
||||
struct LoggingUidSetter {
|
||||
LoggingUidSetter() {}
|
||||
LoggingUidSetter(uint32_t uid) { SetLoggingUid(uid); }
|
||||
virtual ~LoggingUidSetter() { ClearLoggingUid(); }
|
||||
};
|
||||
|
||||
// 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
|
||||
// unit tests.
|
||||
CORE_UTIL_EXPORT void InitLogging();
|
||||
|
||||
// Only enable format specifier warnings on LP64 systems. There is
|
||||
// no easy portable method to handle format specifiers for int64_t.
|
||||
#if (defined(__GNUC__) || defined(__clang__)) && defined(__LP64__)
|
||||
#ifdef __GNUC__
|
||||
[[gnu::format(printf, 5, 6)]] CORE_UTIL_EXPORT void Log(const char* file,
|
||||
const char* function,
|
||||
int line,
|
||||
@@ -49,16 +93,16 @@ CORE_UTIL_EXPORT void Log(const char* file, const char* function, int line,
|
||||
// Log APIs
|
||||
#ifndef LOGE
|
||||
# define LOGE(...) \
|
||||
Log(__FILE__, __func__, __LINE__, wvcdm::LOG_ERROR, __VA_ARGS__)
|
||||
Log(__FILE__, __func__, __LINE__, wvutil::LOG_ERROR, __VA_ARGS__)
|
||||
# define LOGW(...) \
|
||||
Log(__FILE__, __func__, __LINE__, wvcdm::LOG_WARN, __VA_ARGS__)
|
||||
Log(__FILE__, __func__, __LINE__, wvutil::LOG_WARN, __VA_ARGS__)
|
||||
# define LOGI(...) \
|
||||
Log(__FILE__, __func__, __LINE__, wvcdm::LOG_INFO, __VA_ARGS__)
|
||||
Log(__FILE__, __func__, __LINE__, wvutil::LOG_INFO, __VA_ARGS__)
|
||||
# define LOGD(...) \
|
||||
Log(__FILE__, __func__, __LINE__, wvcdm::LOG_DEBUG, __VA_ARGS__)
|
||||
Log(__FILE__, __func__, __LINE__, wvutil::LOG_DEBUG, __VA_ARGS__)
|
||||
# define LOGV(...) \
|
||||
Log(__FILE__, __func__, __LINE__, wvcdm::LOG_VERBOSE, __VA_ARGS__)
|
||||
Log(__FILE__, __func__, __LINE__, wvutil::LOG_VERBOSE, __VA_ARGS__)
|
||||
#endif
|
||||
} // namespace wvcdm
|
||||
} // namespace wvutil
|
||||
|
||||
#endif // WVCDM_UTIL_LOG_H_
|
||||
|
||||
Reference in New Issue
Block a user