From 84d9813b81d498610b5294dd4853ca6eb746f11b Mon Sep 17 00:00:00 2001 From: "John W. Bruce" Date: Wed, 6 Mar 2019 11:18:55 -0800 Subject: [PATCH] Add LOG_SILENT LogPriority Again (This is a merge of http://go/wvgerrit/73743 and http://go/wvgerrit/73903) The CE CDM implements the ability to silence all logging with a "silent" log level. However, under the covers, this assigned a value to g_cutoff that was not a member of LogPriority, which fails some extremely strict checks. This patch just adds a matching entry to LogPriority so that "silent" is now a valid level in that enum. A previous merge of this change broke builds on Elfin because it uses stricter compiler settings that rejected the lack of LOG_SILENT in certain switch statements. I've gone through the codebase and found every switch on a LogLevel variable and updated it, of which only one affects the Android build. Bug: 118622359 Test: CE CDM Build Test: Android Build Test: Android Elfin Build Specifically Change-Id: I6ba3556e0e70f5e7e1692754a8a2f54adae59a6b --- libwvdrmengine/cdm/util/include/log.h | 14 +++++++++----- libwvdrmengine/cdm/util/src/log.cpp | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libwvdrmengine/cdm/util/include/log.h b/libwvdrmengine/cdm/util/include/log.h index ce390a0a..d79ff001 100644 --- a/libwvdrmengine/cdm/util/include/log.h +++ b/libwvdrmengine/cdm/util/include/log.h @@ -14,11 +14,15 @@ namespace wvcdm { // Simple logging class. The implementation is platform dependent. typedef enum { - LOG_ERROR, - LOG_WARN, - LOG_INFO, - LOG_DEBUG, - LOG_VERBOSE + // This log level should only be used for |g_cutoff|, in order to silence all + // logging. It should never be passed to |Log()| as a log level. + LOG_SILENT = -1, + + LOG_ERROR = 0, + LOG_WARN = 1, + LOG_INFO = 2, + LOG_DEBUG = 3, + LOG_VERBOSE = 4, } LogPriority; extern LogPriority g_cutoff; diff --git a/libwvdrmengine/cdm/util/src/log.cpp b/libwvdrmengine/cdm/util/src/log.cpp index 058b6624..8d0a2a7a 100644 --- a/libwvdrmengine/cdm/util/src/log.cpp +++ b/libwvdrmengine/cdm/util/src/log.cpp @@ -61,6 +61,7 @@ void Log(const char* file, const char* function, int line, LogPriority level, android_LogPriority prio = ANDROID_LOG_VERBOSE; switch(level) { + case LOG_SILENT: return; // It is nonsensical to pass LOG_SILENT. case LOG_ERROR: prio = ANDROID_LOG_ERROR; break; case LOG_WARN: prio = ANDROID_LOG_WARN; break; case LOG_INFO: prio = ANDROID_LOG_INFO; break;