@@ -33,7 +33,7 @@ using std::string;
3333
3434namespace
3535{
36- Logger log ;
36+ Logger logger ;
3737GlobalPlugin *plugin;
3838} // namespace
3939
@@ -61,7 +61,7 @@ class GlobalHookPlugin : public GlobalPlugin
6161 void
6262 handleReadRequestHeadersPostRemap (Transaction &transaction) override
6363 {
64- LOG_DEBUG (log ,
64+ LOG_DEBUG (logger ,
6565 " handleReadRequestHeadersPostRemap.\n "
6666 " \t Request URL: %s\n "
6767 " \t Request Path: %s\n "
@@ -74,23 +74,23 @@ class GlobalHookPlugin : public GlobalPlugin
7474 // Next, to demonstrate how you can change logging levels:
7575 if (transaction.getClientRequest ().getUrl ().getPath () == " change_log_level" ) {
7676 if (transaction.getClientRequest ().getUrl ().getQuery ().find (" level=debug" ) != string::npos) {
77- log .setLogLevel (Logger::LOG_LEVEL_DEBUG);
78- LOG_DEBUG (log , " Changed log level to DEBUG" );
77+ logger .setLogLevel (Logger::LOG_LEVEL_DEBUG);
78+ LOG_DEBUG (logger , " Changed log level to DEBUG" );
7979 } else if (transaction.getClientRequest ().getUrl ().getQuery ().find (" level=info" ) != string::npos) {
80- log .setLogLevel (Logger::LOG_LEVEL_INFO);
81- LOG_INFO (log , " Changed log level to INFO" );
80+ logger .setLogLevel (Logger::LOG_LEVEL_INFO);
81+ LOG_INFO (logger , " Changed log level to INFO" );
8282 } else if (transaction.getClientRequest ().getUrl ().getQuery ().find (" level=error" ) != string::npos) {
83- log .setLogLevel (Logger::LOG_LEVEL_ERROR);
84- LOG_ERROR (log , " Changed log level to ERROR" );
83+ logger .setLogLevel (Logger::LOG_LEVEL_ERROR);
84+ LOG_ERROR (logger , " Changed log level to ERROR" );
8585 }
8686 }
8787
8888 // One drawback to using the Traffic Server Text Loggers is that you're limited in the size of the log
8989 // lines, this limit is now set at 8kb for atscppapi, but this limit might be removed in the future.
90- LOG_INFO (log , " This message will be dropped (see error.log) because it's just too big: %s" , big_buffer_14kb_);
90+ LOG_INFO (logger , " This message will be dropped (see error.log) because it's just too big: %s" , big_buffer_14kb_);
9191
9292 // This should work though:
93- LOG_INFO (log , " %s" , big_buffer_6kb_);
93+ LOG_INFO (logger , " %s" , big_buffer_6kb_);
9494
9595 transaction.resume ();
9696 }
@@ -119,24 +119,24 @@ TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED)
119119 // The fifth argument is to enable log rolling, this is enabled by default.
120120 // The sixth argument is the frequency in which we will roll the logs, 300 seconds is very low,
121121 // the default for this argument is 3600.
122- log .init (" logger_example" , true , true , Logger::LOG_LEVEL_DEBUG, true , 300 );
122+ logger .init (" logger_example" , true , true , Logger::LOG_LEVEL_DEBUG, true , 300 );
123123
124124 // Now that we've initialized a logger we can do all kinds of fun things on it:
125- log .setRollingEnabled (true ); // already done via log.init, just an example.
126- log .setRollingIntervalSeconds (300 ); // already done via log.init
125+ logger .setRollingEnabled (true ); // already done via log.init, just an example.
126+ logger .setRollingIntervalSeconds (300 ); // already done via log.init
127127
128128 // You have two ways to log to a logger, you can log directly on the object itself:
129- log .logInfo (" Hello World from: %s" , argv[0 ]);
129+ logger .logInfo (" Hello World from: %s" , argv[0 ]);
130130
131131 // Alternatively you can take advantage of the super helper macros for logging
132132 // that will include the file, function, and line number automatically as part
133133 // of the log message:
134- LOG_INFO (log , " Hello World with more info from: %s" , argv[0 ]);
134+ LOG_INFO (logger , " Hello World with more info from: %s" , argv[0 ]);
135135
136136 // This will hurt performance, but it's an option that's always available to you
137137 // to force flush the logs. Otherwise TrafficServer will flush the logs around
138138 // once every second. You should really avoid flushing the log unless it's really necessary.
139- log .flush ();
139+ logger .flush ();
140140
141141 plugin = new GlobalHookPlugin ();
142142}
0 commit comments