Built motion from commit 2b9af5da.|2.6.26
[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 _0x542c=['format','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','meta','keys','stringify','transports','Logger','File','%s-%s','error','Console','warn','path','moment','winston','../config/environment','debugLevel','toLowerCase','red','bold\x20yellow','white','bold\x20white','bold\x20green','gray','bold\x20magenta','bold\x20blue','bold\x20cyan','addColors','/var/log/xcally','%s-%s.log','message','replace','{{{','}}}'];(function(_0x469393,_0x247969){var _0x5f720d=function(_0x40aeb3){while(--_0x40aeb3){_0x469393['push'](_0x469393['shift']());}};_0x5f720d(++_0x247969);}(_0x542c,0x19a));var _0xc542=function(_0x21d692,_0x487ac6){_0x21d692=_0x21d692-0x0;var _0x54f860=_0x542c[_0x21d692];return _0x54f860;};'use strict';var path=require(_0xc542('0x0'));var util=require('util');var moment=require(_0xc542('0x1'));var winston=require(_0xc542('0x2'));var config=require(_0xc542('0x3'));var debugLevel=config[_0xc542('0x4')]?config[_0xc542('0x4')][_0xc542('0x5')]():'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':_0xc542('0x6'),'warn':_0xc542('0x7'),'info':_0xc542('0x8'),'print':_0xc542('0x9'),'success':_0xc542('0xa'),'http':_0xc542('0xb'),'verbose':_0xc542('0xc'),'debug':_0xc542('0xd'),'silly':_0xc542('0xe')};winston[_0xc542('0xf')](XC_LOG_COLORS);function getLogFileName(_0x2d6c45,_0x25ed74,_0x19f717){var _0x539826=_0x2d6c45||_0xc542('0x10');return path['join'](_0x539826,util['format'](_0xc542('0x11'),_0x25ed74,_0x19f717));}function formatter(_0x33ee25,_0x12e383){_0x12e383[_0xc542('0x12')]=_0x12e383[_0xc542('0x12')][_0xc542('0x13')](/@@{/g,_0xc542('0x14'))['replace'](/}@@/g,_0xc542('0x15'))[_0xc542('0x13')](/@{/g,'{{')[_0xc542('0x13')](/}@/g,'}}');return util[_0xc542('0x16')]('[%s]\x20[%s]\x20%s\x20-\x20%s',moment()[_0xc542('0x16')](_0xc542('0x17')),_0x12e383[_0xc542('0x18')][_0xc542('0x19')](),_0x33ee25,_0x12e383[_0xc542('0x12')]);}function fileFormat(_0x282ddf,_0x4e6d82){_0x4e6d82[_0xc542('0x12')]=_0x4e6d82[_0xc542('0x12')]['replace'](/@@{/g,_0xc542('0x14'))['replace'](/}@@/g,_0xc542('0x15'))[_0xc542('0x13')](/@{/g,'{{')[_0xc542('0x13')](/}@/g,'}}');var _0x5592b3=_0x4e6d82[_0xc542('0x1a')]&&Object[_0xc542('0x1b')](_0x4e6d82[_0xc542('0x1a')])['length']?'\x0a\x09'+JSON[_0xc542('0x1c')](_0x4e6d82[_0xc542('0x1a')]):'';return util[_0xc542('0x16')]('[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s',moment()['format'](_0xc542('0x17')),_0x4e6d82['level'][_0xc542('0x19')](),_0x282ddf,_0x4e6d82[_0xc542('0x12')],_0x5592b3);}function consoleLogger(){var _0x2c8156=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xc542('0x1d'))]['Console']({'level':'warn','json':![],'formatter':function(_0x5c5b57){return formatter('',_0x5c5b57);}})]});return _0x2c8156;}function fileLogger(_0x2a0f0e,_0x23ea6f){var _0x370e0b=new winston[(_0xc542('0x1e'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xc542('0x1d'))][(_0xc542('0x1f'))]({'name':util[_0xc542('0x16')](_0xc542('0x20'),_0x2a0f0e,_0xc542('0x21')),'filename':getLogFileName(_0x23ea6f,_0x2a0f0e,_0xc542('0x21')),'level':_0xc542('0x21'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x252a45){return fileFormat(_0x2a0f0e,_0x252a45);}}),new winston[(_0xc542('0x1d'))][(_0xc542('0x1f'))]({'name':util['format'](_0xc542('0x20'),_0x2a0f0e,debugLevel),'filename':getLogFileName(_0x23ea6f,_0x2a0f0e,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x282130){return fileFormat(_0x2a0f0e,_0x282130);}}),new winston[(_0xc542('0x1d'))][(_0xc542('0x22'))]({'level':_0xc542('0x23'),'json':![],'formatter':function(_0x111dbb){return fileFormat(_0x2a0f0e,_0x111dbb);}})]});return _0x370e0b;}exports['consoleLogger']=consoleLogger;exports['fileLogger']=fileLogger;