Skip to content

Commit

Permalink
Better verbose logging
Browse files Browse the repository at this point in the history
If no valid ipv4 (or an illformed  override)  is detected and there is 1 or more blocks that request an ipv4 update, a warning is logged when verbosity is full. Same applies for undetected ipv6.
  • Loading branch information
bluescan committed Feb 17, 2019
1 parent 22382a6 commit 30459d0
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion TacitDynDns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ void DynDns::UpdateAllServices()
ttfPrintf(Log, "Log: Using IPV6 Override of: %s\n", ipv6.Pod());
}

// Are there any ipv4 blocks?
int numIPV4Blocks = 0;
for (UpdateBlock* block = UpdateBlocks.First(); block; block = block->Next())
if (block->Record == eRecord::IPV4)
numIPV4Blocks++;

// Update ipv4 blocks.
if (ipv4.CountChar('.') == 3)
{
Expand Down Expand Up @@ -275,6 +281,17 @@ void DynDns::UpdateAllServices()
}
}
}
else if (numIPV4Blocks)
{
if (Verbosity >= eLogVerbosity::Full)
ttfPrintf(Log, "Wrn: Unable to update %d IPV4 blocks. No valid IPV4 detected.\n", numIPV4Blocks);
}

// Are there any ipv46blocks?
int numIPV6Blocks = 0;
for (UpdateBlock* block = UpdateBlocks.First(); block; block = block->Next())
if (block->Record == eRecord::IPV6)
numIPV6Blocks++;

// Update ipv6 blocks.
if (ipv6.CountChar(':') == 7)
Expand Down Expand Up @@ -309,6 +326,11 @@ void DynDns::UpdateAllServices()
}
}
}
else if (numIPV6Blocks)
{
if (Verbosity >= eLogVerbosity::Full)
ttfPrintf(Log, "Wrn: Unable to update %d IPV6 blocks. No valid IPV6 detected.\n", numIPV6Blocks);
}
}


Expand Down Expand Up @@ -410,7 +432,7 @@ int main(int argc, char** argv)
}

DynDns::ReadConfigFile(configFile);
if (DynDns::Verbosity != DynDns::eLogVerbosity::None)
if (DynDns::Verbosity > DynDns::eLogVerbosity::None)
DynDns::Log = tOpenFile(DynDns::LogFile.Pod(), "at+");

if (DynDns::Verbosity >= DynDns::eLogVerbosity::Full)
Expand Down

0 comments on commit 30459d0

Please sign in to comment.