Improve debugs() handling in helpers (#1011)
This change also reduces libdebug dependency on globals.cc, improving
libdebug reusability.
Also do not default-reset debug sections after they were explicitly set:
* In most sbin/squid contexts, DebugModule constructor is called before
Debug::parseOptions(). That call order results in the Levels array
being reset to default values before it is reset to configured values.
No problem.
* In sbin/squid -X context, DebugModule constructor is called after
Debug::parseOptions(), but the override_X flag protected the Levels
array from being reset to default values in this case. No problem.
* In helper contexts, DebugModule constructor may be called after
Debug::parseOptions(), and the override_X flag stays false. This order
results in the parseOptions() effects erased by ResetSections() called
from the constructor.
This bug was detected while trying to understand why pinger's hard-coded
(and wrong) ALL,10 default has no effect on pinger's debugging. The two
bugs cancelled each other.
The following changes affect pinger (now) and other helpers that will
eventually use libdebug and its new NameThisHelper() API:
* Label helper debugs() lines with the helper name (e.g., "pinger"),
similar to how we already label SMP debugs() lines with "kidN". This
change improves cache.log readability, distinguishes output from
different helpers, and distinguishes helper output from sbin/squid
output in non-SMP logs.
* Make sure level-1 debugs() messages are logged.
* Stop pointless accumulation of cache.log and syslog channel messages.
* Automatically honor SQUID_DEBUG environment variable set by the parent
Squid process. The pinger helper was already honoring it.
The following changes are specific to pinger:
* Removed the now-duplicated references to "pinger" in pinger debugs().
* Do not default pinger debugging levels to ALL,10. The default pinger
debugging levels should be the same as the default Squid debugging
levels (i.e. "ALL,1"). Bugs in the debugging module prevented the
hard-coded "ALL,10" (or any other elevated setting) from having an
effect, but we now fixed the last of those bugs. AFAICT, the change of
default from ALL,1 to ALL,10 in commit
cc192b5 was accidental.