Browse Source

Add option to skip log-file.

Brian Aker 12 years ago
parent
commit
6bfe655a14
2 changed files with 8 additions and 6 deletions
  1. 1 1
      gearmand/gearmand.cc
  2. 7 5
      gearmand/log.hpp

+ 1 - 1
gearmand/gearmand.cc

@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
    "Number of attempts to run the job before the job server removes it. This is helpful to ensure a bad job does not crash all available workers. Default is no limit.")
 
   ("log-file,l", boost::program_options::value(&log_file)->default_value(LOCALSTATEDIR"/log/gearmand.log"),
-   "Log file to write errors and information to. If the log-file paramater is specified as 'stderr', then output will go to stderr")
+   "Log file to write errors and information to. If the log-file paramater is specified as 'stderr', then output will go to stderr. If 'none', then no logfile will be generated.")
 
   ("listen,L", boost::program_options::value(&host),
    "Address the server should listen on. Default is INADDR_ANY.")

+ 7 - 5
gearmand/log.hpp

@@ -69,7 +69,10 @@ struct gearmand_log_info_st
       if (filename.compare("stderr") == 0)
       {
         fd= STDERR_FILENO;
+        opt_file= true;
       }
+      else if (filename.compare("none") == 0)
+      { }
       else
       {
         fd= open(filename.c_str(), O_CREAT | O_WRONLY | O_APPEND, 0644);
@@ -80,10 +83,9 @@ struct gearmand_log_info_st
 
           char error_mesg[1024];
           int error_mesg_length= snprintf(error_mesg, sizeof(error_mesg),
-                                          "Could not open log file \"%.*s\", from \"%s\", switching to stderr. Open failed with (%s)", 
+                                          "Could not open log file \"%.*s\", from \"%s\", switching to stderr.",
                                           int(filename.size()), filename.c_str(), 
-                                          cwd,
-                                          strerror(errno));
+                                          cwd);
           if (opt_syslog)
           {
             syslog(LOG_ERR, "%.*s", error_mesg_length, error_mesg);
@@ -92,9 +94,9 @@ struct gearmand_log_info_st
 
           fd= STDERR_FILENO;
         }
-      }
 
-      opt_file= true;
+        opt_file= true;
+      }
     }
 
     init_success= true;