-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul of the Logging Infrastructure (#1596)
* Pulled ostream operators for IPAddress and MacAddress into the namespace to satisfy ADL requirements. * Refactor of Logger. - LogLevel is now a top level enum class. - Added a new log level Off to disable output from a specific module. - Logger::LogLevel is a deprecated alias to LogLevel. - Logger::Info, Debug, Error are deprecated aliases to LogLevel::... - Removed public "internal*" functions from Logger.Logger - Added LogSource struct to encapsulate source information. - Added shouldLog method to check if a log should be emitted for a given level and module. - Removed nonfunctional artifacts "m_LogStream" and "Logger::operator<<" - Added templated "log" functions that are friends to Logger. - Reworked PCPP_LOG macros to no longer utilize the now removed internal functions. - Added PCPP_LOG_INFO macro level. - Changed PCPP_LOG_ERROR to now check if the log should be emitted. - Fixed NetworkUtils log module name overlapping with NetworkUtils class. - Fixed missing enum value for PacketLogModuleSll2Layer. * Cleanup and fixes. * Added the new Off log level to the string conversion. * Fixed wrong variable name. * Added documentation to log source. * Lint. * Fixed docstring for LogSource. * Fixed extra / * Fixed explicit warning. * Moved log functions inside logger. * Revert "Moved log functions inside logger." This reverts commit be95ab8. * Moved the log functions to the Logger class. - Added optional compile time elimination of log calls below set level. * Fixed typo in macro names. * Changed value param to const-ref. * Added "venv" and "./out" to ignored directories by codespell. * Reverted to previous optimizations to keep executable binary size low. - Renamed printLogMessage to emit and changed visibility to public. - Added new class LogContext to encapsulate a single emittable log message. - Added new methods createLogContext which is practically a rework of internalCreateLogStream but returns a LogContext. - Added optional use of object pooling optimization for reusing log contexts. (Enabled via preprocessor flag PCPP_LOG_USE_OBJECT_POOL) * Fixed warnings about unreferenced local variables if the compile time minimum log level set to too high severity.. * Removed useless variable. * Fixed friend class definition. * Fixed variable assignment. * Added method useContextPooling to control if the logger should use context pooling. - Removed preprocessor variable PCPP_LOG_USE_OBJECT_POOL. - Disabled context pooling for the unit tests as it interferes with the memory leak checker. * Fixed more warnings about unreferenced local variables if the compile time minimum log level set to too high severity.. * Addressed warnings and documentation. - Added documentation to new methods and classes. - Addressed explicit constructor warnings. - Moved disable of context pooling for unit tests to the main.cpp files of the respective tests. * Fixed include. * Fixed pointer dereference. * Fixed memory checker issues with logger. - Added 2 preallocated log contexts to the object pool. * Lint * Added mutex lock on the default log printer to support proper multi-threading and eliminate possibility of data races during log emission. * Fixed typos in documentation. * Changed level variable to private. * Changed LogPrinter definition to use the metaprogramming construct std::add_pointer. * Replaced C library includes with C++ equivalents. * Updated documentation format. * Added full namespace qualifier for marco code. * Changed C-array to std::array. * Added a mutex lock when writing or reading to last error string to prevent tearing. * Fixed object pool member variables. * Added mutators to change the max size of an object pool at runtime. * Added exception if pool preallocation size is larger then the maximum allowed pool size. * Added tests for ObjectPool<T>. - Changed infinite pool size to be maximum value of size_t instead of 0, to fix an issue if max size is set to 0. - Added size getter to the pool. - Marked the pool mutex as mutable. * Lint * Added option to set the max pool size for the Logger context pool. * Disabled logger context pooling in the tests as it is detected as a false positive memory leak. * Lint * Lint * Updated logger tests. - Changed `pcpp::Logger::getInstance()` to use a cached `logger` variable. - Removed the need for fully qualified names in the logger test. - C-style casts to Cpp casts. * Added tests for `shouldLog`. * Moved iostream and iomanip to Logger.cpp as they are unnessesary in the header. * Lint * Added iostream to examples that depended on transitively including iostream from Logger.h * Added <iomanip> to examples that depended on transitively including from Logger.h * Moved ObjectPool to internal namespace. * Renamed ObjectPool to DynamicObjectPool. * Renamed preallocate ctor parameter to initialSize. * Removed unused logging functions. * Fixed missed include <cstring>.
- Loading branch information
Showing
20 changed files
with
607 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[codespell] | ||
skip = *.dat,typos-config.toml,.git,.venv,./ci,./Dist,./mk,./Tests/ExamplesTest/expected_output,./Tests/ExamplesTest/pcap_examples,./Tests/Packet++Test/PacketExamples,./Tests/Pcap++Test/PcapExamples,./3rdParty,./Examples/PcapSearch/dirent-for-Visual-Studio | ||
skip = *.dat,typos-config.toml,.git,.venv,venv,./out,./ci,./Dist,./mk,./Tests/ExamplesTest/expected_output,./Tests/ExamplesTest/pcap_examples,./Tests/Packet++Test/PacketExamples,./Tests/Pcap++Test/PcapExamples,./3rdParty,./Examples/PcapSearch/dirent-for-Visual-Studio | ||
ignore-words = codespell-ignore-list.txt | ||
count = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -876,5 +876,4 @@ namespace pcpp | |
oss << network.toString(); | ||
return oss; | ||
} | ||
|
||
} // namespace pcpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.