Skip to content

Commit

Permalink
Use fmt for string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mpartio committed Feb 16, 2024
1 parent d93eec5 commit 2f84070
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions himan-plugins/source/hybrid_height.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ void hybrid_height::Calculate(shared_ptr<info<float>> myTargetInfo, unsigned sho
{
auto myThreadedLogger = logger(itsName + "Thread #" + to_string(threadIndex));

myThreadedLogger.Info("Calculating time " + static_cast<string>(myTargetInfo->Time().ValidDateTime()) + " level " +
static_cast<string>(myTargetInfo->Level()) + " forecast type " +
static_cast<string>(myTargetInfo->ForecastType()));
myThreadedLogger.Info(fmt::format("Calculating time {} level {} forecast type {}",
myTargetInfo->Time().ValidDateTime(), myTargetInfo->Level(),
myTargetInfo->ForecastType()));

bool ret;

Expand All @@ -71,13 +71,13 @@ void hybrid_height::Calculate(shared_ptr<info<float>> myTargetInfo, unsigned sho

if (!ret)
{
myThreadedLogger.Warning("Skipping step " + static_cast<string>(myTargetInfo->Time().Step()) + ", level " +
static_cast<string>(myTargetInfo->Level()));
myThreadedLogger.Warning(
fmt::format("Skipping level {} step {}", myTargetInfo->Level(), myTargetInfo->Time().Step()));
return;
}

myThreadedLogger.Info("[CPU] Missing values: " + to_string(myTargetInfo->Data().MissingCount()) + "/" +
to_string(myTargetInfo->Data().Size()));
myThreadedLogger.Info(
fmt::format("[CPU] Missing values: {}/{}", myTargetInfo->Data().MissingCount(), myTargetInfo->Data().Size()));
}

bool hybrid_height::WithGeopotential(shared_ptr<himan::info<float>>& myTargetInfo)
Expand Down Expand Up @@ -247,8 +247,8 @@ bool hybrid_height::WithHypsometricEquation(shared_ptr<himan::info<float>>& myTa

if (!prevTInfo || !prevPInfo || !PInfo || !TInfo)
{
itsLogger.Error("Source data missing for level " + to_string(myTargetInfo->Level().Value()) + " step " +
static_cast<string>(myTargetInfo->Time().Step()) + ", stopping processing");
itsLogger.Error(fmt::format("Source data missing for level {} step {}", myTargetInfo->Level().Value(),
myTargetInfo->Time().Step()));
return false;
}

Expand Down Expand Up @@ -329,8 +329,8 @@ bool hybrid_height::WithHypsometricEquation(shared_ptr<himan::info<float>>& myTa
// processing any level above this one.
if (myTargetInfo->Data().Size() == myTargetInfo->Data().MissingCount())
{
itsLogger.Error("All data missing for level " + to_string(myTargetInfo->Level().Value()) + " step " +
static_cast<string>(myTargetInfo->Time().Step()) + ", stopping processing");
itsLogger.Error(fmt::format("All data missing for level {} step {}", myTargetInfo->Level().Value(),
myTargetInfo->Time().Step()));
return false;
}

Expand All @@ -357,8 +357,7 @@ bool hybrid_height::WithHypsometricEquation(shared_ptr<himan::info<float>>& myTa
auto prevH = Fetch<float>(forecastTime, prevLevel, HParam, forecastType, false);
if (!prevH)
{
itsLogger.Error("Unable to get height of level below level " +
static_cast<string>(myTargetInfo->Level()));
itsLogger.Error(fmt::format("Unable to get height of level below level {}", myTargetInfo->Level()));
return false;
}

Expand Down

0 comments on commit 2f84070

Please sign in to comment.