Built motion from commit 4c281f94.|2.6.31
[motion2.git] / server / utils / loggers.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xdd1e=['message','{{{','replace','}}}','[%s]\x20[%s]\x20%s\x20-\x20%s','YYYY-MM-DD\x20HH:mm:ss','toUpperCase','meta','keys','length','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','Logger','Console','transports','File','%s-%s','error','consoleLogger','path','moment','../config/environment','debugLevel','toLowerCase','info','redBG\x20white','red','bold\x20yellow','bold\x20green','gray','bold\x20blue','join','format'];(function(_0x2e5d4f,_0x551d44){var _0x32de3f=function(_0x49ae31){while(--_0x49ae31){_0x2e5d4f['push'](_0x2e5d4f['shift']());}};_0x32de3f(++_0x551d44);}(_0xdd1e,0x112));var _0xedd1=function(_0x323acd,_0x17c2a8){_0x323acd=_0x323acd-0x0;var _0x1ee4bb=_0xdd1e[_0x323acd];return _0x1ee4bb;};'use strict';var path=require(_0xedd1('0x0'));var util=require('util');var moment=require(_0xedd1('0x1'));var winston=require('winston');var config=require(_0xedd1('0x2'));var debugLevel=config[_0xedd1('0x3')]?config[_0xedd1('0x3')][_0xedd1('0x4')]():_0xedd1('0x5');var XC_LOG_LEVELS={'fatal':0x0,'error':0x0,'warn':0x1,'info':0x2,'print':0x2,'success':0x2,'http':0x3,'verbose':0x4,'debug':0x5,'silly':0x6};var XC_LOG_COLORS={'fatal':_0xedd1('0x6'),'error':_0xedd1('0x7'),'warn':_0xedd1('0x8'),'info':'white','print':'bold\x20white','success':_0xedd1('0x9'),'http':_0xedd1('0xa'),'verbose':'bold\x20magenta','debug':_0xedd1('0xb'),'silly':'bold\x20cyan'};winston['addColors'](XC_LOG_COLORS);function getLogFileName(_0x3f1a7a,_0x27bfb3,_0x25d1da){var _0x33084d=_0x3f1a7a||'/var/log/xcally';return path[_0xedd1('0xc')](_0x33084d,util[_0xedd1('0xd')]('%s-%s.log',_0x27bfb3,_0x25d1da));}function formatter(_0x1cc7e7,_0x2a900a){_0x2a900a[_0xedd1('0xe')]=_0x2a900a[_0xedd1('0xe')]['replace'](/@@{/g,_0xedd1('0xf'))[_0xedd1('0x10')](/}@@/g,_0xedd1('0x11'))[_0xedd1('0x10')](/@{/g,'{{')['replace'](/}@/g,'}}');return util['format'](_0xedd1('0x12'),moment()[_0xedd1('0xd')](_0xedd1('0x13')),_0x2a900a['level'][_0xedd1('0x14')](),_0x1cc7e7,_0x2a900a[_0xedd1('0xe')]);}function fileFormat(_0x369ab9,_0x5e9d23){_0x5e9d23[_0xedd1('0xe')]=_0x5e9d23['message'][_0xedd1('0x10')](/@@{/g,_0xedd1('0xf'))['replace'](/}@@/g,_0xedd1('0x11'))['replace'](/@{/g,'{{')['replace'](/}@/g,'}}');var _0x124785=_0x5e9d23[_0xedd1('0x15')]&&Object[_0xedd1('0x16')](_0x5e9d23[_0xedd1('0x15')])[_0xedd1('0x17')]?'\x0a\x09'+JSON['stringify'](_0x5e9d23[_0xedd1('0x15')]):'';return util[_0xedd1('0xd')](_0xedd1('0x18'),moment()[_0xedd1('0xd')](_0xedd1('0x13')),_0x5e9d23['level']['toUpperCase'](),_0x369ab9,_0x5e9d23['message'],_0x124785);}function consoleLogger(){var _0x1e4b56=new winston[(_0xedd1('0x19'))]({'levels':XC_LOG_LEVELS,'transports':[new winston['transports'][(_0xedd1('0x1a'))]({'level':'warn','json':![],'formatter':function(_0x350f82){return formatter('',_0x350f82);}})]});return _0x1e4b56;}function fileLogger(_0x13f8d7,_0x5ebbe2){var _0x4364f9=new winston[(_0xedd1('0x19'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xedd1('0x1b'))][(_0xedd1('0x1c'))]({'name':util[_0xedd1('0xd')](_0xedd1('0x1d'),_0x13f8d7,_0xedd1('0x1e')),'filename':getLogFileName(_0x5ebbe2,_0x13f8d7,_0xedd1('0x1e')),'level':'error','json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x50e5fc){return fileFormat(_0x13f8d7,_0x50e5fc);}}),new winston[(_0xedd1('0x1b'))]['File']({'name':util[_0xedd1('0xd')](_0xedd1('0x1d'),_0x13f8d7,debugLevel),'filename':getLogFileName(_0x5ebbe2,_0x13f8d7,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x2ab498){return fileFormat(_0x13f8d7,_0x2ab498);}}),new winston[(_0xedd1('0x1b'))][(_0xedd1('0x1a'))]({'level':'warn','json':![],'formatter':function(_0x56acc7){return fileFormat(_0x13f8d7,_0x56acc7);}})]});return _0x4364f9;}exports[_0xedd1('0x1f')]=consoleLogger;exports['fileLogger']=fileLogger;