Navigation Menu

Skip to content

Commit

Permalink
Add --system-log-file option
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 25, 2014
1 parent e83ab6e commit f79018d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
28 changes: 27 additions & 1 deletion bin/droonga-http-server
Expand Up @@ -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'),
Expand Down Expand Up @@ -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',
Expand All @@ -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());
Expand Down Expand Up @@ -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
Expand All @@ -126,6 +151,7 @@ if (options.cacheSize > 0) {

application.droonga({
prefix: '',
logger: logger,
defaultDataset: options.defaultDataset,
tag: options.tag,
server: server,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -26,7 +26,8 @@
"express-droonga": "*",
"express-session": "*",
"morgan": "*",
"response-time": "*"
"response-time": "*",
"winston": "*"
},
"bin": {
"droonga-http-server": "./bin/droonga-http-server"
Expand Down

0 comments on commit f79018d

Please sign in to comment.