Permalink
Browse files

* Create log directories during initialization

  • Loading branch information...
1 parent 7d3dd46 commit 5c61847ca3507a26241506774c4fd0bfd72766f4 @joehewitt committed Sep 12, 2011
Showing with 7 additions and 2 deletions.
  1. +4 −0 logger.js
  2. +3 −2 package.json
View
@@ -1,8 +1,10 @@
var fs = require('fs');
+var path = require('path');
var util = require('util');
var datetime = require('datetime');
var express = require('express');
+var mkdirsSync = require('mkdir').mkdirsSync;
// *************************************************************************************************
@@ -12,6 +14,8 @@ var defaultDateFormat = '%Y-%m-%d';
// *************************************************************************************************
module.exports = function(options) {
+ mkdirsSync(path.dirname(options.path));
+
var logStream = fs.createWriteStream(options.path, {flags: 'a'});
var logger = express.logger({stream: logStream, format: options.format});
View
@@ -1,7 +1,7 @@
{
"name": "express-logger",
"description": "Express middleware for auto-archiving log files.",
- "version": "0.0.1",
+ "version": "0.0.2",
"homepage": "http://github.com/joehewitt/express-logger",
"repository": {
"type": "git",
@@ -11,7 +11,8 @@
"author": "Joe Hewitt <joe@joehewitt.com>",
"dependencies": {
"datetime": "",
- "express": ""
+ "express": "",
+ "mkdir": ""
},
"engines": { "node": ">=0.4.0" },
"main": "./logger"

0 comments on commit 5c61847

Please sign in to comment.