You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/09/28 19:50:55 UTC
[trafficserver] branch 9.0.x updated: Rename ambiguous log variable
(#7199)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new f074d51 Rename ambiguous log variable (#7199)
f074d51 is described below
commit f074d513d27479a682d30212cba0261e622ac74f
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Fri Sep 18 09:04:10 2020 +0900
Rename ambiguous log variable (#7199)
(cherry picked from commit bb5c3908697ad442dc8a4078cdb13be09448dadb)
---
.../cpp-api/logger_example/LoggerExample.cc | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/example/plugins/cpp-api/logger_example/LoggerExample.cc b/example/plugins/cpp-api/logger_example/LoggerExample.cc
index f6b1bfe..9e9561a 100644
--- a/example/plugins/cpp-api/logger_example/LoggerExample.cc
+++ b/example/plugins/cpp-api/logger_example/LoggerExample.cc
@@ -33,7 +33,7 @@ using std::string;
namespace
{
-Logger log;
+Logger logger;
GlobalPlugin *plugin;
} // namespace
@@ -61,7 +61,7 @@ public:
void
handleReadRequestHeadersPostRemap(Transaction &transaction) override
{
- LOG_DEBUG(log,
+ LOG_DEBUG(logger,
"handleReadRequestHeadersPostRemap.\n"
"\tRequest URL: %s\n"
"\tRequest Path: %s\n"
@@ -74,23 +74,23 @@ public:
// Next, to demonstrate how you can change logging levels:
if (transaction.getClientRequest().getUrl().getPath() == "change_log_level") {
if (transaction.getClientRequest().getUrl().getQuery().find("level=debug") != string::npos) {
- log.setLogLevel(Logger::LOG_LEVEL_DEBUG);
- LOG_DEBUG(log, "Changed log level to DEBUG");
+ logger.setLogLevel(Logger::LOG_LEVEL_DEBUG);
+ LOG_DEBUG(logger, "Changed log level to DEBUG");
} else if (transaction.getClientRequest().getUrl().getQuery().find("level=info") != string::npos) {
- log.setLogLevel(Logger::LOG_LEVEL_INFO);
- LOG_INFO(log, "Changed log level to INFO");
+ logger.setLogLevel(Logger::LOG_LEVEL_INFO);
+ LOG_INFO(logger, "Changed log level to INFO");
} else if (transaction.getClientRequest().getUrl().getQuery().find("level=error") != string::npos) {
- log.setLogLevel(Logger::LOG_LEVEL_ERROR);
- LOG_ERROR(log, "Changed log level to ERROR");
+ logger.setLogLevel(Logger::LOG_LEVEL_ERROR);
+ LOG_ERROR(logger, "Changed log level to ERROR");
}
}
// One drawback to using the Traffic Server Text Loggers is that you're limited in the size of the log
// lines, this limit is now set at 8kb for atscppapi, but this limit might be removed in the future.
- LOG_INFO(log, "This message will be dropped (see error.log) because it's just too big: %s", big_buffer_14kb_);
+ LOG_INFO(logger, "This message will be dropped (see error.log) because it's just too big: %s", big_buffer_14kb_);
// This should work though:
- LOG_INFO(log, "%s", big_buffer_6kb_);
+ LOG_INFO(logger, "%s", big_buffer_6kb_);
transaction.resume();
}
@@ -119,24 +119,24 @@ TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED)
// The fifth argument is to enable log rolling, this is enabled by default.
// The sixth argument is the frequency in which we will roll the logs, 300 seconds is very low,
// the default for this argument is 3600.
- log.init("logger_example", true, true, Logger::LOG_LEVEL_DEBUG, true, 300);
+ logger.init("logger_example", true, true, Logger::LOG_LEVEL_DEBUG, true, 300);
// Now that we've initialized a logger we can do all kinds of fun things on it:
- log.setRollingEnabled(true); // already done via log.init, just an example.
- log.setRollingIntervalSeconds(300); // already done via log.init
+ logger.setRollingEnabled(true); // already done via log.init, just an example.
+ logger.setRollingIntervalSeconds(300); // already done via log.init
// You have two ways to log to a logger, you can log directly on the object itself:
- log.logInfo("Hello World from: %s", argv[0]);
+ logger.logInfo("Hello World from: %s", argv[0]);
// Alternatively you can take advantage of the super helper macros for logging
// that will include the file, function, and line number automatically as part
// of the log message:
- LOG_INFO(log, "Hello World with more info from: %s", argv[0]);
+ LOG_INFO(logger, "Hello World with more info from: %s", argv[0]);
// This will hurt performance, but it's an option that's always available to you
// to force flush the logs. Otherwise TrafficServer will flush the logs around
// once every second. You should really avoid flushing the log unless it's really necessary.
- log.flush();
+ logger.flush();
plugin = new GlobalHookPlugin();
}