Built motion from commit b7e79837.|2.6.29
[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 _0x79a5=['addColors','/var/log/xcally','join','format','%s-%s.log','message','replace','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','meta','keys','length','stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','Logger','transports','Console','warn','File','%s-%s','error','consoleLogger','fileLogger','path','util','moment','winston','debugLevel','redBG\x20white','red','bold\x20yellow','white','bold\x20white','bold\x20magenta','bold\x20blue','bold\x20cyan'];(function(_0x13e741,_0x5d3c24){var _0x3f8bb3=function(_0x4440a0){while(--_0x4440a0){_0x13e741['push'](_0x13e741['shift']());}};_0x3f8bb3(++_0x5d3c24);}(_0x79a5,0x165));var _0x579a=function(_0x46d0c9,_0x526bfa){_0x46d0c9=_0x46d0c9-0x0;var _0x174506=_0x79a5[_0x46d0c9];return _0x174506;};'use strict';var path=require(_0x579a('0x0'));var util=require(_0x579a('0x1'));var moment=require(_0x579a('0x2'));var winston=require(_0x579a('0x3'));var config=require('../config/environment');var debugLevel=config[_0x579a('0x4')]?config[_0x579a('0x4')]['toLowerCase']():'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':_0x579a('0x5'),'error':_0x579a('0x6'),'warn':_0x579a('0x7'),'info':_0x579a('0x8'),'print':_0x579a('0x9'),'success':'bold\x20green','http':'gray','verbose':_0x579a('0xa'),'debug':_0x579a('0xb'),'silly':_0x579a('0xc')};winston[_0x579a('0xd')](XC_LOG_COLORS);function getLogFileName(_0x2b78a8,_0x4ce18c,_0x2cc05e){var _0x2a440f=_0x2b78a8||_0x579a('0xe');return path[_0x579a('0xf')](_0x2a440f,util[_0x579a('0x10')](_0x579a('0x11'),_0x4ce18c,_0x2cc05e));}function formatter(_0x3898f8,_0x4c81f8){_0x4c81f8[_0x579a('0x12')]=_0x4c81f8[_0x579a('0x12')]['replace'](/@@{/g,'{{{')[_0x579a('0x13')](/}@@/g,'}}}')[_0x579a('0x13')](/@{/g,'{{')[_0x579a('0x13')](/}@/g,'}}');return util[_0x579a('0x10')]('[%s]\x20[%s]\x20%s\x20-\x20%s',moment()[_0x579a('0x10')](_0x579a('0x14')),_0x4c81f8[_0x579a('0x15')][_0x579a('0x16')](),_0x3898f8,_0x4c81f8['message']);}function fileFormat(_0xaccb67,_0x413b49){_0x413b49['message']=_0x413b49[_0x579a('0x12')][_0x579a('0x13')](/@@{/g,'{{{')['replace'](/}@@/g,'}}}')[_0x579a('0x13')](/@{/g,'{{')[_0x579a('0x13')](/}@/g,'}}');var _0x4ed37f=_0x413b49[_0x579a('0x17')]&&Object[_0x579a('0x18')](_0x413b49[_0x579a('0x17')])[_0x579a('0x19')]?'\x0a\x09'+JSON[_0x579a('0x1a')](_0x413b49['meta']):'';return util[_0x579a('0x10')](_0x579a('0x1b'),moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),_0x413b49[_0x579a('0x15')]['toUpperCase'](),_0xaccb67,_0x413b49[_0x579a('0x12')],_0x4ed37f);}function consoleLogger(){var _0x3e0baf=new winston[(_0x579a('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x579a('0x1d'))][(_0x579a('0x1e'))]({'level':_0x579a('0x1f'),'json':![],'formatter':function(_0x51e9bb){return formatter('',_0x51e9bb);}})]});return _0x3e0baf;}function fileLogger(_0x18abdf,_0x215130){var _0x43f38d=new winston[(_0x579a('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x579a('0x1d'))][(_0x579a('0x20'))]({'name':util[_0x579a('0x10')](_0x579a('0x21'),_0x18abdf,_0x579a('0x22')),'filename':getLogFileName(_0x215130,_0x18abdf,_0x579a('0x22')),'level':'error','json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x266c9b){return fileFormat(_0x18abdf,_0x266c9b);}}),new winston[(_0x579a('0x1d'))][(_0x579a('0x20'))]({'name':util[_0x579a('0x10')](_0x579a('0x21'),_0x18abdf,debugLevel),'filename':getLogFileName(_0x215130,_0x18abdf,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x4ff696){return fileFormat(_0x18abdf,_0x4ff696);}}),new winston['transports']['Console']({'level':_0x579a('0x1f'),'json':![],'formatter':function(_0x37cec7){return fileFormat(_0x18abdf,_0x37cec7);}})]});return _0x43f38d;}exports[_0x579a('0x23')]=consoleLogger;exports[_0x579a('0x24')]=fileLogger;