/*jshint esversion:6, node:true*/
'use strict';

var winston = require('winston');
var config = require('winston/lib/winston/config');
var Message = require('../logger').Message;

/*
 * Winston:
 * We use the Console and daily rotate file transports
 * and if provided, we also use Honeybadger.
 */
var transports = [
    new (winston.transports.Console)({
        handleExceptions: true,
        prettyPrint: true,
        silent: false,
        timestamp: 'hh:mm:ss',
        colorize: true,
        json: false,
        formatter: function(options) {
            var message = new Message()
                .setColorizer(config.colorize)
                .setTime(options.timestamp)
                .setLabel(options.label)
                .setLevel(options.level)
                .setFrom(options.from)
                .setMessage(options.message);

            if(options.meta){
                if(options.meta.loggerName) {
                    message.setLoggerName(options.meta.loggerName);
                }
            }

            return message.toString();
        }
    }),
    new (winston.transports.File)({
        filename: 'debug.log',
        // filename: './${app.name}-debug.log',
        name: 'file.debug',
        level: 'debug',
        maxsize: 1024000,
        maxFiles: 3,
        handleExceptions: true,
        json: false
    })
];

module.exports = {
    transports: transports,
    exceptionHandlers: [
        new winston.transports.File({
            filename: 'exceptions.log',
            maxsize: 1024000,
            maxFiles: 3,
            name: 'file.exceptions',
            json: false
        })
    ]
};

/*
 * This get's executed after we have solved
 * our dependencies and before we return the
 * final config object.
 */
 module.exports.afterSolver = function(config){
     console.log('config', config);
     /*
      * If we are in production, get rid of the
      */
     if(config.get('environment', 'production') === 'production'){
         var transports = [];
         config.logger.transports.map((tr)=> {
             if(tr.name === 'file.debug') return;
             transports.push(tr);
         });
         config.logger.transports =  transports;
     }

 };

@@ -1816,44 +1816,8 @@
 g)%7B%0A
-     console.log('config', config);%0A
     

remove cruft