< prev index next >

src/share/vm/logging/logConfiguration.cpp

Print this page
rev 11858 : [mq]: 8157948.01

@@ -42,10 +42,13 @@
 size_t      LogConfiguration::_n_outputs = 0;
 
 LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = NULL;
 size_t      LogConfiguration::_n_listener_callbacks = 0;
 
+// LogFileOutput is the default type of output, its type prefix should be used if no type was specified
+static const char* implicit_output_prefix = LogFileOutput::Prefix;
+
 // Stack object to take the lock for configuring the logging.
 // Should only be held during the critical parts of the configuration
 // (when calling configure_output or reading/modifying the outputs array).
 // Thread must never block when holding this lock.
 class ConfigurationLock : public StackObj {

@@ -106,10 +109,11 @@
   }
   FREE_C_HEAP_ARRAY(LogOutput*, _outputs);
 }
 
 // Normalizes the given LogOutput name to type=name form.
+// For example, foo, "foo", file="foo", will all be normalized to file=foo (no quotes, prefixed).
 static bool normalize_output_name(const char* full_name, char* buffer, size_t len, outputStream* errstream) {
   const char* start_quote = strchr(full_name, '"');
   const char* equals = strchr(full_name, '=');
   const bool quoted = start_quote != NULL;
   const bool is_stdout_or_stderr = (strcmp(full_name, "stdout") == 0 || strcmp(full_name, "stderr") == 0);

@@ -126,11 +130,11 @@
     // split on equals sign
     name = equals + 1;
     prefix = full_name;
     prefix_len = equals - full_name + 1;
   } else if (!is_stdout_or_stderr) {
-    prefix = "file=";
+    prefix = implicit_output_prefix;
     prefix_len = strlen(prefix);
   }
   size_t name_len = strlen(name);
 
   if (quoted) {

@@ -166,11 +170,11 @@
 
 LogOutput* LogConfiguration::new_output(const char* name,
                                         const char* options,
                                         outputStream* errstream) {
   LogOutput* output;
-  if (strncmp(name, "file=", strlen("file=")) == 0) {
+  if (strncmp(name, LogFileOutput::Prefix, strlen(LogFileOutput::Prefix)) == 0) {
     output = new LogFileOutput(name);
   } else {
     errstream->print_cr("Unsupported log output type: %s", name);
     return NULL;
   }

@@ -393,11 +397,11 @@
       errstream->print_cr("Invalid output index '%s'", outputstr);
       return false;
     }
   } else { // Output specified using name
     // Normalize the name, stripping quotes and ensures it includes type prefix
-    size_t len = strlen(outputstr) + strlen("file=") + 1;
+    size_t len = strlen(outputstr) + strlen(implicit_output_prefix) + 1;
     char* normalized = NEW_C_HEAP_ARRAY(char, len, mtLogging);
     if (!normalize_output_name(outputstr, normalized, len, errstream)) {
       return false;
     }
 
< prev index next >