6dd85fa4d645ec2d892be7238632888c732d3d18
[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 _0xfb9a=['error','consoleLogger','path','util','moment','winston','../config/environment','debugLevel','toLowerCase','info','redBG\x20white','red','bold\x20yellow','white','bold\x20white','bold\x20green','bold\x20blue','addColors','/var/log/xcally','join','format','%s-%s.log','message','replace','}}}','level','{{{','meta','keys','stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','YYYY-MM-DD\x20HH:mm:ss','toUpperCase','Logger','Console','warn','transports','File','%s-%s'];(function(_0x46ee1c,_0x45a091){var _0x23d17b=function(_0x29348b){while(--_0x29348b){_0x46ee1c['push'](_0x46ee1c['shift']());}};_0x23d17b(++_0x45a091);}(_0xfb9a,0x188));var _0xafb9=function(_0x3906f4,_0x5c1da7){_0x3906f4=_0x3906f4-0x0;var _0x57d3d8=_0xfb9a[_0x3906f4];return _0x57d3d8;};'use strict';var path=require(_0xafb9('0x0'));var util=require(_0xafb9('0x1'));var moment=require(_0xafb9('0x2'));var winston=require(_0xafb9('0x3'));var config=require(_0xafb9('0x4'));var debugLevel=config[_0xafb9('0x5')]?config['debugLevel'][_0xafb9('0x6')]():_0xafb9('0x7');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':_0xafb9('0x8'),'error':_0xafb9('0x9'),'warn':_0xafb9('0xa'),'info':_0xafb9('0xb'),'print':_0xafb9('0xc'),'success':_0xafb9('0xd'),'http':'gray','verbose':'bold\x20magenta','debug':_0xafb9('0xe'),'silly':'bold\x20cyan'};winston[_0xafb9('0xf')](XC_LOG_COLORS);function getLogFileName(_0x42c131,_0x4b9bfc,_0x1df284){var _0x264a34=_0x42c131||_0xafb9('0x10');return path[_0xafb9('0x11')](_0x264a34,util[_0xafb9('0x12')](_0xafb9('0x13'),_0x4b9bfc,_0x1df284));}function formatter(_0x52b33c,_0x37ee0b){_0x37ee0b[_0xafb9('0x14')]=_0x37ee0b[_0xafb9('0x14')][_0xafb9('0x15')](/@@{/g,'{{{')[_0xafb9('0x15')](/}@@/g,_0xafb9('0x16'))[_0xafb9('0x15')](/@{/g,'{{')[_0xafb9('0x15')](/}@/g,'}}');return util[_0xafb9('0x12')]('[%s]\x20[%s]\x20%s\x20-\x20%s',moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),_0x37ee0b[_0xafb9('0x17')]['toUpperCase'](),_0x52b33c,_0x37ee0b[_0xafb9('0x14')]);}function fileFormat(_0x53b27c,_0x47fee7){_0x47fee7[_0xafb9('0x14')]=_0x47fee7[_0xafb9('0x14')][_0xafb9('0x15')](/@@{/g,_0xafb9('0x18'))[_0xafb9('0x15')](/}@@/g,_0xafb9('0x16'))[_0xafb9('0x15')](/@{/g,'{{')[_0xafb9('0x15')](/}@/g,'}}');var _0x2e459a=_0x47fee7[_0xafb9('0x19')]&&Object[_0xafb9('0x1a')](_0x47fee7[_0xafb9('0x19')])['length']?'\x0a\x09'+JSON[_0xafb9('0x1b')](_0x47fee7[_0xafb9('0x19')]):'';return util['format'](_0xafb9('0x1c'),moment()[_0xafb9('0x12')](_0xafb9('0x1d')),_0x47fee7['level'][_0xafb9('0x1e')](),_0x53b27c,_0x47fee7[_0xafb9('0x14')],_0x2e459a);}function consoleLogger(){var _0x1aeee6=new winston[(_0xafb9('0x1f'))]({'levels':XC_LOG_LEVELS,'transports':[new winston['transports'][(_0xafb9('0x20'))]({'level':_0xafb9('0x21'),'json':![],'formatter':function(_0x1918d8){return formatter('',_0x1918d8);}})]});return _0x1aeee6;}function fileLogger(_0x1adaa8,_0x2e577a){var _0x37ff85=new winston[(_0xafb9('0x1f'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xafb9('0x22'))][(_0xafb9('0x23'))]({'name':util[_0xafb9('0x12')](_0xafb9('0x24'),_0x1adaa8,_0xafb9('0x25')),'filename':getLogFileName(_0x2e577a,_0x1adaa8,_0xafb9('0x25')),'level':_0xafb9('0x25'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x3c3883){return fileFormat(_0x1adaa8,_0x3c3883);}}),new winston[(_0xafb9('0x22'))]['File']({'name':util[_0xafb9('0x12')]('%s-%s',_0x1adaa8,debugLevel),'filename':getLogFileName(_0x2e577a,_0x1adaa8,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x1fed0c){return fileFormat(_0x1adaa8,_0x1fed0c);}}),new winston[(_0xafb9('0x22'))][(_0xafb9('0x20'))]({'level':_0xafb9('0x21'),'json':![],'formatter':function(_0x4827fc){return fileFormat(_0x1adaa8,_0x4827fc);}})]});return _0x37ff85;}exports[_0xafb9('0x26')]=consoleLogger;exports['fileLogger']=fileLogger;