[Groonga-commit] droonga/droonga-http-server at f79018d [master] Add --system-log-file option

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Apr 25 16:52:52 JST 2014


Kouhei Sutou	2014-04-25 16:52:52 +0900 (Fri, 25 Apr 2014)

  New Revision: f79018d29399e0d926e43ffe2d377e53d45e045b
  https://github.com/droonga/droonga-http-server/commit/f79018d29399e0d926e43ffe2d377e53d45e045b

  Message:
    Add --system-log-file option

  Modified files:
    bin/droonga-http-server
    package.json

  Modified: bin/droonga-http-server (+27 -1)
===================================================================
--- bin/droonga-http-server    2014-04-25 16:32:49 +0900 (e1f4d5b)
+++ bin/droonga-http-server    2014-04-25 16:52:52 +0900 (1c5afad)
@@ -3,6 +3,7 @@
 
 var fs = require('fs'),
     daemon = require('daemon'),
+    winston = require('winston'),
     express = require('express'),
     bodyParser = require('body-parser'),
     cookieParser = require('cookie-parser'),
@@ -43,6 +44,9 @@ options
   .option('--access-log-file <file>',
           'Output access logs to <file>. ' +
             'You can use "-" as <file> to output to the standard output.')
+  .option('--system-log-file <file>',
+          'Output system logs to <file>. ' +
+            'You can use "-" as <file> to output to the standard output.')
   .option('--cache-size <size>', 'The max number of cached requests',
           intOption, 100)
   .option('--enable-trust-proxy',
@@ -63,6 +67,26 @@ if (options.daemon) {
   daemon();
 }
 
+var logger;
+if (options.systemLogFile) {
+  logger = new winston.Logger({
+    transports: [
+      new winston.transports.File({
+        filename: options.systemLogFile,
+        json: false
+      })
+    ]
+  });
+} else {
+  var transports = [];
+  if (!options.daemon) {
+    transports.push(new winston.transports.Console());
+  }
+  logger = new winston.Logger({
+    transports: transports
+  });
+}
+
 if (options.pidFile) {
   var fd = fs.openSync(options.pidFile, 'w', 0644);
   fs.writeSync(fd, process.pid.toString());
@@ -112,7 +136,8 @@ if (options.cacheSize > 0) {
     application.use("/statistics/cache",
                     droonga.middleware.cacheStatistics(cache));
     application.use(droonga.middleware.cache(cache, {
-      rules: cacheMiddlewareRules
+      rules: cacheMiddlewareRules,
+      logger: logger
     }));
   } else if (droonga.cache) {
     // TODO: Remove me when express-droonga 1.0.2 is released and
@@ -126,6 +151,7 @@ if (options.cacheSize > 0) {
 
 application.droonga({
   prefix: '',
+  logger: logger,
   defaultDataset: options.defaultDataset,
   tag: options.tag,
   server: server,

  Modified: package.json (+2 -1)
===================================================================
--- package.json    2014-04-25 16:32:49 +0900 (5139569)
+++ package.json    2014-04-25 16:52:52 +0900 (3222641)
@@ -26,7 +26,8 @@
     "express-droonga": "*",
     "express-session": "*",
     "morgan": "*",
-    "response-time": "*"
+    "response-time": "*",
+    "winston": "*"
   },
   "bin": {
     "droonga-http-server": "./bin/droonga-http-server"
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index