bfb69c886ebd74e710ce69afb4a5edc2e0021ab1
[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 _0xcbec=['stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','transports','Console','warn','Logger','File','%s-%s','error','consoleLogger','path','util','winston','../config/environment','debugLevel','toLowerCase','info','redBG\x20white','red','bold\x20yellow','white','bold\x20green','gray','bold\x20magenta','bold\x20blue','addColors','/var/log/xcally','join','format','message','replace','{{{','[%s]\x20[%s]\x20%s\x20-\x20%s','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','meta','keys','length'];(function(_0x52dbf0,_0x29c062){var _0x5bc746=function(_0x139edf){while(--_0x139edf){_0x52dbf0['push'](_0x52dbf0['shift']());}};_0x5bc746(++_0x29c062);}(_0xcbec,0x7f));var _0xccbe=function(_0x1c46c5,_0x41bc70){_0x1c46c5=_0x1c46c5-0x0;var _0x4e403c=_0xcbec[_0x1c46c5];return _0x4e403c;};'use strict';var path=require(_0xccbe('0x0'));var util=require(_0xccbe('0x1'));var moment=require('moment');var winston=require(_0xccbe('0x2'));var config=require(_0xccbe('0x3'));var debugLevel=config[_0xccbe('0x4')]?config[_0xccbe('0x4')][_0xccbe('0x5')]():_0xccbe('0x6');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':_0xccbe('0x7'),'error':_0xccbe('0x8'),'warn':_0xccbe('0x9'),'info':_0xccbe('0xa'),'print':'bold\x20white','success':_0xccbe('0xb'),'http':_0xccbe('0xc'),'verbose':_0xccbe('0xd'),'debug':_0xccbe('0xe'),'silly':'bold\x20cyan'};winston[_0xccbe('0xf')](XC_LOG_COLORS);function getLogFileName(_0x41c400,_0x4e1045,_0xa9f511){var _0x50aa09=_0x41c400||_0xccbe('0x10');return path[_0xccbe('0x11')](_0x50aa09,util[_0xccbe('0x12')]('%s-%s.log',_0x4e1045,_0xa9f511));}function formatter(_0x20f666,_0x27eea4){_0x27eea4['message']=_0x27eea4[_0xccbe('0x13')][_0xccbe('0x14')](/@@{/g,_0xccbe('0x15'))[_0xccbe('0x14')](/}@@/g,'}}}')[_0xccbe('0x14')](/@{/g,'{{')[_0xccbe('0x14')](/}@/g,'}}');return util[_0xccbe('0x12')](_0xccbe('0x16'),moment()[_0xccbe('0x12')](_0xccbe('0x17')),_0x27eea4[_0xccbe('0x18')][_0xccbe('0x19')](),_0x20f666,_0x27eea4[_0xccbe('0x13')]);}function fileFormat(_0x21b1b9,_0x285292){_0x285292[_0xccbe('0x13')]=_0x285292[_0xccbe('0x13')]['replace'](/@@{/g,_0xccbe('0x15'))['replace'](/}@@/g,'}}}')[_0xccbe('0x14')](/@{/g,'{{')['replace'](/}@/g,'}}');var _0xb978ac=_0x285292[_0xccbe('0x1a')]&&Object[_0xccbe('0x1b')](_0x285292[_0xccbe('0x1a')])[_0xccbe('0x1c')]?'\x0a\x09'+JSON[_0xccbe('0x1d')](_0x285292['meta']):'';return util['format'](_0xccbe('0x1e'),moment()['format'](_0xccbe('0x17')),_0x285292[_0xccbe('0x18')]['toUpperCase'](),_0x21b1b9,_0x285292['message'],_0xb978ac);}function consoleLogger(){var _0x25e4c0=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xccbe('0x1f'))][(_0xccbe('0x20'))]({'level':_0xccbe('0x21'),'json':![],'formatter':function(_0x1b0b42){return formatter('',_0x1b0b42);}})]});return _0x25e4c0;}function fileLogger(_0x32efc7,_0x807cc6){var _0x3097a7=new winston[(_0xccbe('0x22'))]({'levels':XC_LOG_LEVELS,'transports':[new winston['transports'][(_0xccbe('0x23'))]({'name':util[_0xccbe('0x12')](_0xccbe('0x24'),_0x32efc7,_0xccbe('0x25')),'filename':getLogFileName(_0x807cc6,_0x32efc7,'error'),'level':_0xccbe('0x25'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x294722){return fileFormat(_0x32efc7,_0x294722);}}),new winston['transports'][(_0xccbe('0x23'))]({'name':util[_0xccbe('0x12')](_0xccbe('0x24'),_0x32efc7,debugLevel),'filename':getLogFileName(_0x807cc6,_0x32efc7,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x3b473c){return fileFormat(_0x32efc7,_0x3b473c);}}),new winston['transports'][(_0xccbe('0x20'))]({'level':_0xccbe('0x21'),'json':![],'formatter':function(_0x3791ef){return fileFormat(_0x32efc7,_0x3791ef);}})]});return _0x3097a7;}exports[_0xccbe('0x26')]=consoleLogger;exports['fileLogger']=fileLogger;