Built motion from commit a679711e.|2.6.15
[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 _0xea85=['keys','length','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','YYYY-MM-DD\x20HH:mm:ss','level','transports','Console','warn','File','%s-%s','error','consoleLogger','path','util','moment','winston','../config/environment','debugLevel','toLowerCase','info','redBG\x20white','red','bold\x20yellow','white','bold\x20white','bold\x20green','gray','bold\x20blue','bold\x20cyan','/var/log/xcally','join','%s-%s.log','message','replace','format','{{{','meta'];(function(_0x142b97,_0x88f2ed){var _0x472db0=function(_0x13bcb8){while(--_0x13bcb8){_0x142b97['push'](_0x142b97['shift']());}};_0x472db0(++_0x88f2ed);}(_0xea85,0x159));var _0x5ea8=function(_0x39762e,_0x42e66c){_0x39762e=_0x39762e-0x0;var _0x108448=_0xea85[_0x39762e];return _0x108448;};'use strict';var path=require(_0x5ea8('0x0'));var util=require(_0x5ea8('0x1'));var moment=require(_0x5ea8('0x2'));var winston=require(_0x5ea8('0x3'));var config=require(_0x5ea8('0x4'));var debugLevel=config[_0x5ea8('0x5')]?config[_0x5ea8('0x5')][_0x5ea8('0x6')]():_0x5ea8('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':_0x5ea8('0x8'),'error':_0x5ea8('0x9'),'warn':_0x5ea8('0xa'),'info':_0x5ea8('0xb'),'print':_0x5ea8('0xc'),'success':_0x5ea8('0xd'),'http':_0x5ea8('0xe'),'verbose':'bold\x20magenta','debug':_0x5ea8('0xf'),'silly':_0x5ea8('0x10')};winston['addColors'](XC_LOG_COLORS);function getLogFileName(_0x35cf42,_0x23625f,_0x48fa7b){var _0x423588=_0x35cf42||_0x5ea8('0x11');return path[_0x5ea8('0x12')](_0x423588,util['format'](_0x5ea8('0x13'),_0x23625f,_0x48fa7b));}function formatter(_0x58cbf1,_0x597567){_0x597567['message']=_0x597567[_0x5ea8('0x14')]['replace'](/@@{/g,'{{{')[_0x5ea8('0x15')](/}@@/g,'}}}')[_0x5ea8('0x15')](/@{/g,'{{')['replace'](/}@/g,'}}');return util['format']('[%s]\x20[%s]\x20%s\x20-\x20%s',moment()[_0x5ea8('0x16')]('YYYY-MM-DD\x20HH:mm:ss'),_0x597567['level']['toUpperCase'](),_0x58cbf1,_0x597567['message']);}function fileFormat(_0x468ade,_0x1f5f05){_0x1f5f05['message']=_0x1f5f05['message'][_0x5ea8('0x15')](/@@{/g,_0x5ea8('0x17'))[_0x5ea8('0x15')](/}@@/g,'}}}')['replace'](/@{/g,'{{')[_0x5ea8('0x15')](/}@/g,'}}');var _0x2d9a3d=_0x1f5f05[_0x5ea8('0x18')]&&Object[_0x5ea8('0x19')](_0x1f5f05['meta'])[_0x5ea8('0x1a')]?'\x0a\x09'+JSON['stringify'](_0x1f5f05[_0x5ea8('0x18')]):'';return util['format'](_0x5ea8('0x1b'),moment()[_0x5ea8('0x16')](_0x5ea8('0x1c')),_0x1f5f05[_0x5ea8('0x1d')]['toUpperCase'](),_0x468ade,_0x1f5f05[_0x5ea8('0x14')],_0x2d9a3d);}function consoleLogger(){var _0x124c2c=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x5ea8('0x1e'))][(_0x5ea8('0x1f'))]({'level':_0x5ea8('0x20'),'json':![],'formatter':function(_0x4ead09){return formatter('',_0x4ead09);}})]});return _0x124c2c;}function fileLogger(_0x46016a,_0x377260){var _0x4f6a59=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x5ea8('0x1e'))][(_0x5ea8('0x21'))]({'name':util['format'](_0x5ea8('0x22'),_0x46016a,_0x5ea8('0x23')),'filename':getLogFileName(_0x377260,_0x46016a,_0x5ea8('0x23')),'level':_0x5ea8('0x23'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x208f32){return fileFormat(_0x46016a,_0x208f32);}}),new winston[(_0x5ea8('0x1e'))][(_0x5ea8('0x21'))]({'name':util['format'](_0x5ea8('0x22'),_0x46016a,debugLevel),'filename':getLogFileName(_0x377260,_0x46016a,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x1d9f15){return fileFormat(_0x46016a,_0x1d9f15);}}),new winston[(_0x5ea8('0x1e'))][(_0x5ea8('0x1f'))]({'level':_0x5ea8('0x20'),'json':![],'formatter':function(_0x5e9378){return fileFormat(_0x46016a,_0x5e9378);}})]});return _0x4f6a59;}exports[_0x5ea8('0x24')]=consoleLogger;exports['fileLogger']=fileLogger;