Built motion from commit 85328c08.|2.5.50
[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 _0x61fb=['replace','{{{','}}}','[%s]\x20[%s]\x20%s\x20-\x20%s','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','meta','length','stringify','Logger','transports','Console','warn','File','%s-%s','error','consoleLogger','fileLogger','util','moment','../config/environment','debugLevel','toLowerCase','redBG\x20white','red','bold\x20green','gray','bold\x20magenta','bold\x20cyan','addColors','format','%s-%s.log','message'];(function(_0x4bb30f,_0x2f9149){var _0x2685c1=function(_0x25550a){while(--_0x25550a){_0x4bb30f['push'](_0x4bb30f['shift']());}};_0x2685c1(++_0x2f9149);}(_0x61fb,0x1ef));var _0xb61f=function(_0x36643f,_0x5e3acb){_0x36643f=_0x36643f-0x0;var _0x1ab487=_0x61fb[_0x36643f];return _0x1ab487;};'use strict';var path=require('path');var util=require(_0xb61f('0x0'));var moment=require(_0xb61f('0x1'));var winston=require('winston');var config=require(_0xb61f('0x2'));var debugLevel=config[_0xb61f('0x3')]?config['debugLevel'][_0xb61f('0x4')]():'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':_0xb61f('0x5'),'error':_0xb61f('0x6'),'warn':'bold\x20yellow','info':'white','print':'bold\x20white','success':_0xb61f('0x7'),'http':_0xb61f('0x8'),'verbose':_0xb61f('0x9'),'debug':'bold\x20blue','silly':_0xb61f('0xa')};winston[_0xb61f('0xb')](XC_LOG_COLORS);function getLogFileName(_0x5930e3,_0x22c670,_0x2fd383){var _0x5e23dd=_0x5930e3||'/var/log/xcally';return path['join'](_0x5e23dd,util[_0xb61f('0xc')](_0xb61f('0xd'),_0x22c670,_0x2fd383));}function formatter(_0x33d381,_0x386765){_0x386765[_0xb61f('0xe')]=_0x386765['message'][_0xb61f('0xf')](/@@{/g,_0xb61f('0x10'))['replace'](/}@@/g,_0xb61f('0x11'))['replace'](/@{/g,'{{')[_0xb61f('0xf')](/}@/g,'}}');return util[_0xb61f('0xc')](_0xb61f('0x12'),moment()['format'](_0xb61f('0x13')),_0x386765[_0xb61f('0x14')][_0xb61f('0x15')](),_0x33d381,_0x386765[_0xb61f('0xe')]);}function fileFormat(_0x17fd0d,_0x77bc58){_0x77bc58[_0xb61f('0xe')]=_0x77bc58[_0xb61f('0xe')]['replace'](/@@{/g,'{{{')['replace'](/}@@/g,'}}}')[_0xb61f('0xf')](/@{/g,'{{')['replace'](/}@/g,'}}');var _0x5d1eee=_0x77bc58[_0xb61f('0x16')]&&Object['keys'](_0x77bc58[_0xb61f('0x16')])[_0xb61f('0x17')]?'\x0a\x09'+JSON[_0xb61f('0x18')](_0x77bc58['meta']):'';return util[_0xb61f('0xc')]('[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s',moment()[_0xb61f('0xc')](_0xb61f('0x13')),_0x77bc58[_0xb61f('0x14')][_0xb61f('0x15')](),_0x17fd0d,_0x77bc58[_0xb61f('0xe')],_0x5d1eee);}function consoleLogger(){var _0x464bc9=new winston[(_0xb61f('0x19'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xb61f('0x1a'))][(_0xb61f('0x1b'))]({'level':_0xb61f('0x1c'),'json':![],'formatter':function(_0x3c6af9){return formatter('',_0x3c6af9);}})]});return _0x464bc9;}function fileLogger(_0x2447c1,_0x4b1ccb){var _0x4a84a7=new winston[(_0xb61f('0x19'))]({'levels':XC_LOG_LEVELS,'transports':[new winston['transports'][(_0xb61f('0x1d'))]({'name':util[_0xb61f('0xc')](_0xb61f('0x1e'),_0x2447c1,_0xb61f('0x1f')),'filename':getLogFileName(_0x4b1ccb,_0x2447c1,_0xb61f('0x1f')),'level':'error','json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x2910ae){return fileFormat(_0x2447c1,_0x2910ae);}}),new winston['transports'][(_0xb61f('0x1d'))]({'name':util['format'](_0xb61f('0x1e'),_0x2447c1,debugLevel),'filename':getLogFileName(_0x4b1ccb,_0x2447c1,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x738903){return fileFormat(_0x2447c1,_0x738903);}}),new winston[(_0xb61f('0x1a'))][(_0xb61f('0x1b'))]({'level':_0xb61f('0x1c'),'json':![],'formatter':function(_0x14feee){return fileFormat(_0x2447c1,_0x14feee);}})]});return _0x4a84a7;}exports[_0xb61f('0x20')]=consoleLogger;exports[_0xb61f('0x21')]=fileLogger;