/**
 * Created by Fatih on 21.2.2016.
 */
'use strict';
var winston = require('winston'),config = require('../config'),winstonMongod = require('winston-mongodb').MongoDB;

var logger = new(winston.Logger)({
    transports : [
        new (winston.transports.Console)(),
        new(winston.transports.MongoDB)({
            db : config.db.uri,
            //db : 'mongodb://' + config.db.options.user + ':' + config.db.options.pass + '@' + config.db.host + ':' + config.db.port + '/' + config.db.dbName,
            host :  config.db.host,
            username :config.db.options.user,
            password : config.db.options.password,
            handleExceptions: config.db.winstonHandleExceptions
        })
    ],
    exitOnError: config.db.winstonExitOnError
});

exports.writeLog = function (type, content) {
    logger.log(type, content);
};


exports.writeLogwithMetaData = function (type, content, interpolation) {
    if(process.env.NODE_ENV === 'development')
        console.log(content);
    logger.log(type, content, interpolation);
};

exports.justVisibleLog = function(content){
    if(process.env.NODE_ENV === 'development')
        console.log(content);
};

