Built motion from commit 0900f080.|2.5.45
[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 _0x45ec=['transports','Console','File','%s-%s','error','warn','consoleLogger','fileLogger','path','util','../config/environment','debugLevel','toLowerCase','red','white','bold\x20white','bold\x20green','gray','bold\x20magenta','bold\x20cyan','addColors','join','format','%s-%s.log','message','replace','{{{','}}}','[%s]\x20[%s]\x20%s\x20-\x20%s','level','meta','length','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','YYYY-MM-DD\x20HH:mm:ss','Logger'];(function(_0x59af38,_0x8dbd6d){var _0x1f183e=function(_0x10cf05){while(--_0x10cf05){_0x59af38['push'](_0x59af38['shift']());}};_0x1f183e(++_0x8dbd6d);}(_0x45ec,0x120));var _0xc45e=function(_0x1f753a,_0x32cfa7){_0x1f753a=_0x1f753a-0x0;var _0x511472=_0x45ec[_0x1f753a];return _0x511472;};'use strict';var path=require(_0xc45e('0x0'));var util=require(_0xc45e('0x1'));var moment=require('moment');var winston=require('winston');var config=require(_0xc45e('0x2'));var debugLevel=config['debugLevel']?config[_0xc45e('0x3')][_0xc45e('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':'redBG\x20white','error':_0xc45e('0x5'),'warn':'bold\x20yellow','info':_0xc45e('0x6'),'print':_0xc45e('0x7'),'success':_0xc45e('0x8'),'http':_0xc45e('0x9'),'verbose':_0xc45e('0xa'),'debug':'bold\x20blue','silly':_0xc45e('0xb')};winston[_0xc45e('0xc')](XC_LOG_COLORS);function getLogFileName(_0x27eccb,_0x3476b1,_0x1e333f){var _0x4335c1=_0x27eccb||'/var/log/xcally';return path[_0xc45e('0xd')](_0x4335c1,util[_0xc45e('0xe')](_0xc45e('0xf'),_0x3476b1,_0x1e333f));}function formatter(_0x4be01b,_0x2d5c25){_0x2d5c25[_0xc45e('0x10')]=_0x2d5c25['message'][_0xc45e('0x11')](/@@{/g,_0xc45e('0x12'))[_0xc45e('0x11')](/}@@/g,_0xc45e('0x13'))[_0xc45e('0x11')](/@{/g,'{{')[_0xc45e('0x11')](/}@/g,'}}');return util[_0xc45e('0xe')](_0xc45e('0x14'),moment()[_0xc45e('0xe')]('YYYY-MM-DD\x20HH:mm:ss'),_0x2d5c25[_0xc45e('0x15')]['toUpperCase'](),_0x4be01b,_0x2d5c25[_0xc45e('0x10')]);}function fileFormat(_0x5b597d,_0x371212){_0x371212[_0xc45e('0x10')]=_0x371212[_0xc45e('0x10')][_0xc45e('0x11')](/@@{/g,_0xc45e('0x12'))[_0xc45e('0x11')](/}@@/g,_0xc45e('0x13'))[_0xc45e('0x11')](/@{/g,'{{')[_0xc45e('0x11')](/}@/g,'}}');var _0x45871d=_0x371212[_0xc45e('0x16')]&&Object['keys'](_0x371212[_0xc45e('0x16')])[_0xc45e('0x17')]?'\x0a\x09'+JSON['stringify'](_0x371212[_0xc45e('0x16')]):'';return util[_0xc45e('0xe')](_0xc45e('0x18'),moment()['format'](_0xc45e('0x19')),_0x371212[_0xc45e('0x15')]['toUpperCase'](),_0x5b597d,_0x371212[_0xc45e('0x10')],_0x45871d);}function consoleLogger(){var _0x244ce8=new winston[(_0xc45e('0x1a'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xc45e('0x1b'))][(_0xc45e('0x1c'))]({'level':'warn','json':![],'formatter':function(_0x3883ed){return formatter('',_0x3883ed);}})]});return _0x244ce8;}function fileLogger(_0x3c505a,_0x9e88e6){var _0x58ec64=new winston[(_0xc45e('0x1a'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xc45e('0x1b'))][(_0xc45e('0x1d'))]({'name':util[_0xc45e('0xe')](_0xc45e('0x1e'),_0x3c505a,'error'),'filename':getLogFileName(_0x9e88e6,_0x3c505a,_0xc45e('0x1f')),'level':_0xc45e('0x1f'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x18a1ac){return fileFormat(_0x3c505a,_0x18a1ac);}}),new winston[(_0xc45e('0x1b'))][(_0xc45e('0x1d'))]({'name':util[_0xc45e('0xe')]('%s-%s',_0x3c505a,debugLevel),'filename':getLogFileName(_0x9e88e6,_0x3c505a,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x27ae95){return fileFormat(_0x3c505a,_0x27ae95);}}),new winston['transports'][(_0xc45e('0x1c'))]({'level':_0xc45e('0x20'),'json':![],'formatter':function(_0x1a0bd1){return fileFormat(_0x3c505a,_0x1a0bd1);}})]});return _0x58ec64;}exports[_0xc45e('0x21')]=consoleLogger;exports[_0xc45e('0x22')]=fileLogger;