var fs = require('fs');
var cluster = require('cluster');

exports['default'] = {
  logger: function(api){
    var logger = {transports: []};

    // console logger
    if(cluster.isMaster){
      logger.transports.push(function(api, winston){
        return new (winston.transports.Console)({
          colorize: true,
          level: 'info',
          timestamp: true,
        });
      });
    }

    // file logger
    if(api.config.general.paths.log.length === 1){
      var logDirectory = api.config.general.paths.log[0];
      try{
        fs.mkdirSync(logDirectory);
      }catch(e){
        if(e.code !== 'EEXIST'){
          throw(new Error('Cannot create log directory @ ' + logDirectory));
        }
      }
    }

    logger.transports.push(function(api, winston){
      return new (winston.transports.File)({
        filename: api.config.general.paths.log[0] + '/' + api.pids.title + '.log',
        level: 'info',
        timestamp: true
      });
    });

    // the maximum length of param to log (we will truncate)
    logger.maxLogStringLength = 100;

    // you can optionally set custom log levels
    // logger.levels = {good: 0, bad: 1};

    // you can optionally set custom log colors
    // logger.colors = {good: 'blue', bad: 'red'};

    return logger;
  }
};

exports.test = {
  logger: function(api){
    return {
      transports: null
    };
  }
};

@@ -409,24 +409,77 @@
 file logger%0A
+    logger.transports.push(function(api, winston)%7B%0A  
     if(api.c
@@ -519,24 +519,26 @@
 = 1)%7B%0A      
+  
 var logDirec
@@ -587,13 +587,17 @@
     
+  
 try%7B%0A
+  
     
@@ -634,16 +634,18 @@
 ;%0A      
+ 
+ 
 %7Dcatch(e
@@ -647,16 +647,18 @@
 tch(e)%7B%0A
+  
         
@@ -682,16 +682,18 @@
 XIST')%7B%0A
+  
         
@@ -765,22 +765,16 @@
 ));%0A    
-    %7D%0A
       %7D%0A
@@ -781,61 +781,22 @@
     
-%7D%0A%0A    logger.transports.push(function(api, winston)%7B
+    %7D%0A      %7D%0A
 %0A   

Support when actionhero is installed on read-only filesystem - Delay creation of log directory until after all config has been loaded