Built motion from commit ba71417a.|2.6.28
[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 _0xce97=['format','%s-%s.log','message','replace','{{{','}}}','[%s]\x20[%s]\x20%s\x20-\x20%s','level','meta','length','stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','YYYY-MM-DD\x20HH:mm:ss','toUpperCase','Logger','transports','Console','File','%s-%s','error','warn','consoleLogger','path','util','moment','winston','../config/environment','debugLevel','toLowerCase','redBG\x20white','bold\x20yellow','white','bold\x20white','bold\x20magenta','bold\x20blue','addColors','/var/log/xcally','join'];(function(_0x43906f,_0x296186){var _0x2cf05d=function(_0x325baf){while(--_0x325baf){_0x43906f['push'](_0x43906f['shift']());}};_0x2cf05d(++_0x296186);}(_0xce97,0x1b8));var _0x7ce9=function(_0x97ea3c,_0x211196){_0x97ea3c=_0x97ea3c-0x0;var _0x12ab59=_0xce97[_0x97ea3c];return _0x12ab59;};'use strict';var path=require(_0x7ce9('0x0'));var util=require(_0x7ce9('0x1'));var moment=require(_0x7ce9('0x2'));var winston=require(_0x7ce9('0x3'));var config=require(_0x7ce9('0x4'));var debugLevel=config[_0x7ce9('0x5')]?config[_0x7ce9('0x5')][_0x7ce9('0x6')]():'info';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':_0x7ce9('0x7'),'error':'red','warn':_0x7ce9('0x8'),'info':_0x7ce9('0x9'),'print':_0x7ce9('0xa'),'success':'bold\x20green','http':'gray','verbose':_0x7ce9('0xb'),'debug':_0x7ce9('0xc'),'silly':'bold\x20cyan'};winston[_0x7ce9('0xd')](XC_LOG_COLORS);function getLogFileName(_0x4977a4,_0x170bfa,_0x3d9ffc){var _0x4e3250=_0x4977a4||_0x7ce9('0xe');return path[_0x7ce9('0xf')](_0x4e3250,util[_0x7ce9('0x10')](_0x7ce9('0x11'),_0x170bfa,_0x3d9ffc));}function formatter(_0x955293,_0x32a497){_0x32a497[_0x7ce9('0x12')]=_0x32a497[_0x7ce9('0x12')][_0x7ce9('0x13')](/@@{/g,_0x7ce9('0x14'))[_0x7ce9('0x13')](/}@@/g,_0x7ce9('0x15'))[_0x7ce9('0x13')](/@{/g,'{{')[_0x7ce9('0x13')](/}@/g,'}}');return util['format'](_0x7ce9('0x16'),moment()[_0x7ce9('0x10')]('YYYY-MM-DD\x20HH:mm:ss'),_0x32a497[_0x7ce9('0x17')]['toUpperCase'](),_0x955293,_0x32a497[_0x7ce9('0x12')]);}function fileFormat(_0x56b6c0,_0xc4c6e8){_0xc4c6e8['message']=_0xc4c6e8['message'][_0x7ce9('0x13')](/@@{/g,'{{{')[_0x7ce9('0x13')](/}@@/g,'}}}')[_0x7ce9('0x13')](/@{/g,'{{')[_0x7ce9('0x13')](/}@/g,'}}');var _0x22294c=_0xc4c6e8[_0x7ce9('0x18')]&&Object['keys'](_0xc4c6e8['meta'])[_0x7ce9('0x19')]?'\x0a\x09'+JSON[_0x7ce9('0x1a')](_0xc4c6e8[_0x7ce9('0x18')]):'';return util[_0x7ce9('0x10')](_0x7ce9('0x1b'),moment()[_0x7ce9('0x10')](_0x7ce9('0x1c')),_0xc4c6e8['level'][_0x7ce9('0x1d')](),_0x56b6c0,_0xc4c6e8[_0x7ce9('0x12')],_0x22294c);}function consoleLogger(){var _0x5205f7=new winston[(_0x7ce9('0x1e'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x7ce9('0x1f'))][(_0x7ce9('0x20'))]({'level':'warn','json':![],'formatter':function(_0x5c16bd){return formatter('',_0x5c16bd);}})]});return _0x5205f7;}function fileLogger(_0x3d7a8c,_0x17ca2e){var _0x167181=new winston[(_0x7ce9('0x1e'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x7ce9('0x1f'))][(_0x7ce9('0x21'))]({'name':util[_0x7ce9('0x10')](_0x7ce9('0x22'),_0x3d7a8c,'error'),'filename':getLogFileName(_0x17ca2e,_0x3d7a8c,_0x7ce9('0x23')),'level':_0x7ce9('0x23'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0xfd8113){return fileFormat(_0x3d7a8c,_0xfd8113);}}),new winston[(_0x7ce9('0x1f'))]['File']({'name':util[_0x7ce9('0x10')](_0x7ce9('0x22'),_0x3d7a8c,debugLevel),'filename':getLogFileName(_0x17ca2e,_0x3d7a8c,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x29df1c){return fileFormat(_0x3d7a8c,_0x29df1c);}}),new winston['transports'][(_0x7ce9('0x20'))]({'level':_0x7ce9('0x24'),'json':![],'formatter':function(_0xa692ca){return fileFormat(_0x3d7a8c,_0xa692ca);}})]});return _0x167181;}exports[_0x7ce9('0x25')]=consoleLogger;exports['fileLogger']=fileLogger;