Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate logging to std::format #1751

Open
wants to merge 1 commit into
base: Piers
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/cdm/cdm/media/cdm/cdm_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ void CdmAdapter::Initialize()

if (!library_)
{
LOG::LogF(LOGERROR, "%s: Failed to load library: %s", __FUNCTION__,
error.ToString().c_str());
LOG::LogF(LOGERROR, "{}: Failed to load library: {}", __FUNCTION__, error.ToString().c_str());
return;
}

Expand All @@ -258,7 +257,7 @@ void CdmAdapter::Initialize()
}

std::string version{get_cdm_verion_func()};
LOG::LogF(LOGDEBUG, "CDM version: %s", version.c_str());
LOG::LogF(LOGDEBUG, "CDM version: {}", version.c_str());

#if defined(OS_WIN)
// Load DXVA before sandbox lockdown to give CDM access to Output Protection
Expand Down Expand Up @@ -624,8 +623,8 @@ void CdmAdapter::OnSessionKeysChange(const char* session_id,
char* bufferPtr{buffer};
for (uint32_t j{0}; j < keys_info[i].key_id_size; ++j)
bufferPtr += std::snprintf(bufferPtr, 3, "%02X", (int)keys_info[i].key_id[j]);
LOG::Log(LOGDEBUG, "%s: Sessionkey %s status: %d syscode: %u", __func__, buffer,
keys_info[i].status, keys_info[i].system_code);
LOG::Log(LOGDEBUG, "{}: Sessionkey {} status: {} syscode: {}", __func__, buffer,
static_cast<int>(keys_info[i].status), keys_info[i].system_code);

SendClientMessage(session_id, session_id_size, CdmAdapterClient::kSessionKeysChange,
keys_info[i].key_id, keys_info[i].key_id_size, keys_info[i].status);
Expand Down Expand Up @@ -700,7 +699,7 @@ void CdmAdapter::RequestStorageId(uint32_t version)

void CdmAdapter::OnInitialized(bool success)
{
LOG::LogF(LOGDEBUG, "CDM is initialized: %s", success ? "true" : "false");
LOG::LogF(LOGDEBUG, "CDM is initialized: {}", success ? "true" : "false");
}


Expand Down Expand Up @@ -758,7 +757,7 @@ void CdmFileIoImpl::Write(const uint8_t* data, uint32_t data_size)
{
if (!ExistsDir(base_path_.c_str()) && !CreateDirs(base_path_.c_str()))
{
LOG::LogF(LOGERROR, "Cannot create directory: %s", base_path_.c_str());
LOG::LogF(LOGERROR, "Cannot create directory: {}", base_path_.c_str());
client_->OnWriteComplete(cdm::FileIOClient::Status::kError);
return;
}
Expand Down
36 changes: 18 additions & 18 deletions src/CompKodiProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ constexpr std::string_view PROP_CHOOSER_RES_SECURE_MAX = "inputstream.adaptive.c

void LogProp(std::string_view name, std::string_view value, bool isValueRedacted = false)
{
LOG::Log(LOGDEBUG, "Property found \"%s\" value: %s", name.data(),
LOG::Log(LOGDEBUG, "Property found \"{}\" value: {}", name.data(),
isValueRedacted ? "[redacted]" : value.data());
}

Expand All @@ -87,7 +87,7 @@ void LogDrmJsonDictKeys(std::string_view keyName,
keys += it->name.GetString();
}
LOG::Log(LOGDEBUG,
"Found DRM config for key system: \"%s\" -> Dictionary: \"%s\", Values: \"%s\"",
"Found DRM config for key system: \"{}\" -> Dictionary: \"{}\", Values: \"{}\"",
keySystem.data(), keyName.data(), keys.c_str());
}
}
Expand Down Expand Up @@ -218,7 +218,7 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
if (STRING::GetMapValue(ADP::SETTINGS::RES_CONV_LIST, prop.second, res))
m_chooserProps.m_resolutionMax = res;
else
LOG::Log(LOGERROR, "Resolution not valid on \"%s\" property.", prop.first.c_str());
LOG::Log(LOGERROR, "Resolution not valid on \"{}\" property.", prop.first.c_str());
}
else if (prop.first == PROP_CHOOSER_RES_SECURE_MAX)
{
Expand All @@ -227,7 +227,7 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
if (STRING::GetMapValue(ADP::SETTINGS::RES_CONV_LIST, prop.second, res))
m_chooserProps.m_resolutionSecureMax = res;
else
LOG::Log(LOGERROR, "Resolution not valid on \"%s\" property.", prop.first.c_str());
LOG::Log(LOGERROR, "Resolution not valid on \"{}\" property.", prop.first.c_str());
}
else if (prop.first == PROP_CONFIG)
{
Expand All @@ -243,14 +243,14 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
{
LogProp(prop.first, prop.second, isRedacted);
if (!ParseDrmConfig(prop.second))
LOG::LogF(LOGERROR, "Cannot parse \"%s\" property, wrong or malformed data.",
prop.first.c_str());
LOG::LogF(LOGERROR, "Cannot parse \"{}\" property, wrong or malformed data.",
prop.first.c_str());
}
else if (prop.first == PROP_DRM_LEGACY && !prop.second.empty())
{
LogProp(prop.first, prop.second, isRedacted);
if (!ParseDrmLegacyConfig(prop.second))
LOG::LogF(LOGERROR, "Cannot parse \"%s\" property, wrong or malformed data.",
LOG::LogF(LOGERROR, "Cannot parse \"{}\" property, wrong or malformed data.",
prop.first.c_str());
}
else
Expand All @@ -262,7 +262,7 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
{
continue;
}
LOG::Log(LOGWARNING, "Property found \"%s\" is not supported", prop.first.c_str());
LOG::Log(LOGWARNING, "Property found \"{}\" is not supported", prop.first.c_str());
continue;
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseConfig(const std::string& data)

if (!jDoc.IsObject())
{
LOG::LogF(LOGERROR, "Malformed JSON data in to \"%s\" property", PROP_MANIFEST_CONFIG.data());
LOG::LogF(LOGERROR, "Malformed JSON data in to \"{}\" property", PROP_MANIFEST_CONFIG.data());
return;
}

Expand All @@ -316,7 +316,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseConfig(const std::string& data)
}
else
{
LOG::LogF(LOGERROR, "Unsupported \"%s\" config or wrong data type on \"%s\" property",
LOG::LogF(LOGERROR, "Unsupported \"{}\" config or wrong data type on \"{}\" property",
configName.c_str(), PROP_MANIFEST_CONFIG.data());
}
}
Expand All @@ -333,7 +333,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseManifestConfig(const std::string& dat

if (!jDoc.IsObject())
{
LOG::LogF(LOGERROR, "Malformed JSON data in to \"%s\" property", PROP_MANIFEST_CONFIG.data());
LOG::LogF(LOGERROR, "Malformed JSON data in to \"{}\" property", PROP_MANIFEST_CONFIG.data());
return;
}

Expand Down Expand Up @@ -366,7 +366,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseManifestConfig(const std::string& dat
}
else
{
LOG::LogF(LOGERROR, "Unsupported \"%s\" config or wrong data type on \"%s\" property",
LOG::LogF(LOGERROR, "Unsupported \"{}\" config or wrong data type on \"{}\" property",
configName.c_str(), PROP_MANIFEST_CONFIG.data());
}
}
Expand Down Expand Up @@ -406,7 +406,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
if (!DRM::IsValidKeySystem(drmKeySystem))
{
LOG::LogF(LOGERROR,
"Cannot parse DRM configuration, unknown key system \"%s\" on license_type property",
"Cannot parse DRM configuration, unknown key system \"{}\" on license_type property",
drmKeySystem.c_str());
return;
}
Expand Down Expand Up @@ -541,7 +541,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
{
LOG::Log(
LOGERROR,
"Unknown \"%s\" parameter in the \"response data\" field of license_key property",
"Unknown \"{}\" parameter in the \"response data\" field of license_key property",
wrapperPrefix.data());
}

Expand Down Expand Up @@ -593,7 +593,7 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmConfig(const std::string& data)

if (!jDoc.IsObject())
{
LOG::LogF(LOGERROR, "Malformed JSON data in to \"%s\" property", PROP_DRM.data());
LOG::LogF(LOGERROR, "Malformed JSON data in to \"{}\" property", PROP_DRM.data());
return false;
}

Expand All @@ -604,7 +604,7 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmConfig(const std::string& data)

if (!DRM::IsValidKeySystem(keySystem))
{
LOG::LogF(LOGERROR, "Ignored unknown key system \"%s\" on DRM property", keySystem);
LOG::LogF(LOGERROR, "Ignored unknown key system \"{}\" on DRM property", keySystem);
continue;
}

Expand All @@ -613,7 +613,7 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmConfig(const std::string& data)

if (!jDictVal.IsObject())
{
LOG::LogF(LOGERROR, "Cannot parse key system \"%s\" value on DRM property, wrong data type",
LOG::LogF(LOGERROR, "Cannot parse key system \"{}\" value on DRM property, wrong data type",
keySystem);
continue;
}
Expand Down Expand Up @@ -742,7 +742,7 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmLegacyConfig(const std::string& da

if (!DRM::IsValidKeySystem(keySystem))
{
LOG::LogF(LOGERROR, "Unknown key system \"%s\" on DRM legacy property", keySystem.data());
LOG::LogF(LOGERROR, "Unknown key system \"{}\" on DRM legacy property", keySystem.data());
return false;
}

Expand Down
38 changes: 20 additions & 18 deletions src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool SESSION::CSession::Initialize(std::string manifestUrl)
SetSupportedDecrypterURN(supportedKeySystems);
for (std::string_view keySystem : supportedKeySystems)
{
LOG::Log(LOGDEBUG, "Supported URN: %s", keySystem.data());
LOG::Log(LOGDEBUG, "Supported URN: {}", keySystem.data());
}
}

Expand Down Expand Up @@ -179,7 +179,7 @@ bool SESSION::CSession::Initialize(std::string manifestUrl)

if (!m_adaptiveTree->Open(manifestResp.effectiveUrl, manifestResp.headers, manifestResp.data))
{
LOG::Log(LOGERROR, "Cannot parse the manifest (%s)", manifestUrl.c_str());
LOG::Log(LOGERROR, "Cannot parse the manifest ({})", manifestUrl.c_str());
return false;
}

Expand Down Expand Up @@ -223,7 +223,7 @@ void SESSION::CSession::CheckHDCP()
if (repr->GetHdcpVersion() > ssd_caps.hdcpVersion ||
(ssd_caps.hdcpLimit > 0 && repr->GetWidth() * repr->GetHeight() > ssd_caps.hdcpLimit))
{
LOG::Log(LOGDEBUG, "Representation ID \"%s\" removed as not HDCP compliant",
LOG::Log(LOGDEBUG, "Representation ID \"{}\" removed as not HDCP compliant",
repr->GetId().data());
itRepr = adp->GetRepresentations().erase(itRepr);
}
Expand Down Expand Up @@ -251,7 +251,8 @@ bool SESSION::CSession::PreInitializeDRM(std::string& challengeB64,

if (psshData.empty() || kidData.empty())
{
LOG::LogF(LOGERROR, "Invalid DRM pre-init data, must be as: {PSSH as base64}|{KID as base64}");
LOG::LogF(LOGERROR,
"Invalid DRM pre-init data, must be as: {{PSSH as base64}}|{{KID as base64}}");
return false;
}

Expand Down Expand Up @@ -287,7 +288,7 @@ bool SESSION::CSession::PreInitializeDRM(std::string& challengeB64,
CCdmSession& session(m_cdmSessions[1]);

std::string hexKid{STRING::ToHexadecimal(decKid)};
LOG::LogF(LOGDEBUG, "Initializing session with KID: %s", hexKid.c_str());
LOG::LogF(LOGDEBUG, "Initializing session with KID: {}", hexKid.c_str());

if (m_decrypter && (session.m_cencSingleSampleDecrypter =
m_decrypter->CreateSingleSampleDecrypter(initData, decKid, "", true,
Expand Down Expand Up @@ -379,7 +380,7 @@ bool SESSION::CSession::InitializeDRM(bool addDefaultKID /* = false */)
}
else
{
LOG::Log(LOGDEBUG, "License data: Create Widevine PSSH for SmoothStreaming %s",
LOG::Log(LOGDEBUG, "License data: Create Widevine PSSH for SmoothStreaming {}",
customInitData.empty() ? "" : "(with custom data)");

initData =
Expand Down Expand Up @@ -428,7 +429,7 @@ bool SESSION::CSession::InitializeDRM(bool addDefaultKID /* = false */)

if (!defaultKid.empty())
{
LOG::Log(LOGDEBUG, "Initializing stream with KID: %s", defaultKidStr.c_str());
LOG::Log(LOGDEBUG, "Initializing stream with KID: {}", defaultKidStr.c_str());

// If a decrypter has the default KID, re-use the same decrypter for also this session
for (size_t i{1}; i < ses; ++i)
Expand Down Expand Up @@ -577,7 +578,8 @@ bool SESSION::CSession::InitializePeriod(bool isSessionOpened /* = false */)

if (adp->GetStreamType() == StreamType::NOTYPE)
{
LOG::LogF(LOGDEBUG, "Skipped streams on adaptation set id \"%s\" due to unsupported/unknown type",
LOG::LogF(LOGDEBUG,
"Skipped streams on adaptation set id \"{}\" due to unsupported/unknown type",
adp->GetId().data());
continue;
}
Expand Down Expand Up @@ -697,7 +699,7 @@ void SESSION::CSession::UpdateStream(CStream& stream)

if (rep->GetContainerType() == ContainerType::INVALID)
{
LOG::LogF(LOGERROR, "Container type not valid on stream representation ID: %s",
LOG::LogF(LOGERROR, "Container type not valid on stream representation ID: {}",
rep->GetId().data());
stream.m_isValid = false;
return;
Expand Down Expand Up @@ -792,7 +794,7 @@ void SESSION::CSession::UpdateStream(CStream& stream)
stream.m_info.SetCodecProfile(STREAMCODEC_PROFILE::VP9CodecProfile3);
break;
default:
LOG::LogF(LOGWARNING, "Unhandled video codec profile \"%i\" for codec string: %s",
LOG::LogF(LOGWARNING, "Unhandled video codec profile \"{}\" for codec string: {}",
codecProfileNum, codecStr.c_str());
break;
}
Expand Down Expand Up @@ -907,7 +909,7 @@ bool SESSION::CSession::IsCDMSessionSecurePath(size_t index)
{
if (index >= m_cdmSessions.size())
{
LOG::LogF(LOGERROR, "No CDM session at index %u", index);
LOG::LogF(LOGERROR, "No CDM session at index {}", index);
return false;
}

Expand All @@ -919,7 +921,7 @@ std::string SESSION::CSession::GetCDMSession(unsigned int index)
{
if (index >= m_cdmSessions.size())
{
LOG::LogF(LOGERROR, "No CDM session at index %u", index);
LOG::LogF(LOGERROR, "No CDM session at index {}", index);
return {};
}
return m_cdmSessions[index].m_sessionId;
Expand All @@ -930,7 +932,7 @@ std::shared_ptr<Adaptive_CencSingleSampleDecrypter> SESSION::CSession::GetSingle
{
if (index >= m_cdmSessions.size())
{
LOG::LogF(LOGERROR, "Index %u out of range, cannot get single sample decrypter", index);
LOG::LogF(LOGERROR, "Index {} out of range, cannot get single sample decrypter", index);
return nullptr;
}

Expand Down Expand Up @@ -1104,7 +1106,7 @@ bool SESSION::CSession::SeekTime(double seekTime, unsigned int streamId, bool pr

if ((*pi).get() != m_adaptiveTree->m_currentPeriod)
{
LOG::Log(LOGDEBUG, "SeekTime: seeking into new chapter: %d",
LOG::Log(LOGDEBUG, "SeekTime: seeking into new chapter: {}",
static_cast<int>((pi - m_adaptiveTree->m_periods.begin()) + 1));
SeekChapter(static_cast<int>(pi - m_adaptiveTree->m_periods.begin()) + 1);
m_chapterSeekTime = seekTime;
Expand Down Expand Up @@ -1194,8 +1196,8 @@ bool SESSION::CSession::SeekTime(double seekTime, unsigned int streamId, bool pr
double destTime{static_cast<double>(PTSToElapsed(streamReader->PTS())) /
STREAM_TIME_BASE};
LOG::Log(LOGINFO,
"Seek time %0.1lf for stream: %u (physical index %u) continues at %0.1lf "
"(PTS: %llu)",
"Seek time {:0.1f} for stream: {} (physical index {}) continues at {:0.1f} "
"(PTS: {})",
seekTime, streamReader->GetStreamId(), stream->m_info.GetPhysicalIndex(),
destTime, streamReader->PTS());
if (stream->m_info.GetStreamType() == INPUTSTREAM_TYPE_VIDEO)
Expand Down Expand Up @@ -1282,7 +1284,7 @@ bool SESSION::CSession::OnGetStream(int streamid, kodi::addon::InputstreamInfo&
// we are forced to delete all CStream's here, so that when demux reader will starts
// will have no data to process, and so stop the playback
// (other streams may have been requested/opened before this one)
LOG::Log(LOGERROR, "GetStream(%d): Decrypter for the stream not found", streamid);
LOG::Log(LOGERROR, "GetStream({}): Decrypter for the stream not found", streamid);
DeleteStreams();
return false;
}
Expand Down Expand Up @@ -1428,7 +1430,7 @@ bool SESSION::CSession::SeekChapter(int ch)
{
CPeriod* nextPeriod = m_adaptiveTree->m_periods[ch].get();
m_adaptiveTree->m_nextPeriod = nextPeriod;
LOG::LogF(LOGDEBUG, "Switching to new Period (id=%s, start=%llu, seq=%u)",
LOG::LogF(LOGDEBUG, "Switching to new Period (id={}, start={}, seq={})",
nextPeriod->GetId().data(), nextPeriod->GetStart(), nextPeriod->GetSequence());

for (auto& stream : m_streams)
Expand Down
2 changes: 1 addition & 1 deletion src/aes_decrypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void AESDecrypter::decrypt(const AP4_UI08* aes_key,
reinterpret_cast<AP4_Size*>(&dataSize), lastChunk);
if (!AP4_SUCCEEDED(result))
{
LOG::LogF(LOGERROR, "AES decryption failed: %d", result);
LOG::LogF(LOGERROR, "AES decryption failed: {}", result);
}
dst.resize(dstOffset + dataSize);
}
Expand Down
3 changes: 2 additions & 1 deletion src/codechandler/ttml/TTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ bool TTML2SRT::ParseData(const void* buffer, size_t bufferSize)

if (parseRes.status != status_ok)
{
LOG::LogF(LOGERROR, "Failed to parse XML data, error code: %i", parseRes.status);
LOG::LogF(LOGERROR, "Failed to parse XML data, error code: {}",
static_cast<int>(parseRes.status));
return false;
}

Expand Down
Loading
Loading