Built motion from commit d5e4af8c.|2.6.23
[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 _0x5b7d=['redBG\x20white','red','bold\x20yellow','white','bold\x20white','bold\x20green','addColors','/var/log/xcally','format','%s-%s.log','message','replace','}}}','YYYY-MM-DD\x20HH:mm:ss','level','{{{','meta','keys','length','stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','toUpperCase','Logger','transports','Console','warn','error','File','%s-%s','fileLogger','moment','winston','../config/environment','debugLevel','toLowerCase','info'];(function(_0x371f8d,_0x2d7355){var _0x3ed5fc=function(_0x1809ae){while(--_0x1809ae){_0x371f8d['push'](_0x371f8d['shift']());}};_0x3ed5fc(++_0x2d7355);}(_0x5b7d,0x8a));var _0xd5b7=function(_0x42f226,_0x54d9a4){_0x42f226=_0x42f226-0x0;var _0x385118=_0x5b7d[_0x42f226];return _0x385118;};'use strict';var path=require('path');var util=require('util');var moment=require(_0xd5b7('0x0'));var winston=require(_0xd5b7('0x1'));var config=require(_0xd5b7('0x2'));var debugLevel=config[_0xd5b7('0x3')]?config[_0xd5b7('0x3')][_0xd5b7('0x4')]():_0xd5b7('0x5');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':_0xd5b7('0x6'),'error':_0xd5b7('0x7'),'warn':_0xd5b7('0x8'),'info':_0xd5b7('0x9'),'print':_0xd5b7('0xa'),'success':_0xd5b7('0xb'),'http':'gray','verbose':'bold\x20magenta','debug':'bold\x20blue','silly':'bold\x20cyan'};winston[_0xd5b7('0xc')](XC_LOG_COLORS);function getLogFileName(_0x443cde,_0x3f1e0b,_0x4cbfce){var _0x326ef9=_0x443cde||_0xd5b7('0xd');return path['join'](_0x326ef9,util[_0xd5b7('0xe')](_0xd5b7('0xf'),_0x3f1e0b,_0x4cbfce));}function formatter(_0xe20b48,_0x3469aa){_0x3469aa[_0xd5b7('0x10')]=_0x3469aa[_0xd5b7('0x10')]['replace'](/@@{/g,'{{{')[_0xd5b7('0x11')](/}@@/g,_0xd5b7('0x12'))[_0xd5b7('0x11')](/@{/g,'{{')['replace'](/}@/g,'}}');return util[_0xd5b7('0xe')]('[%s]\x20[%s]\x20%s\x20-\x20%s',moment()[_0xd5b7('0xe')](_0xd5b7('0x13')),_0x3469aa[_0xd5b7('0x14')]['toUpperCase'](),_0xe20b48,_0x3469aa[_0xd5b7('0x10')]);}function fileFormat(_0x3862a2,_0x159b97){_0x159b97[_0xd5b7('0x10')]=_0x159b97['message'][_0xd5b7('0x11')](/@@{/g,_0xd5b7('0x15'))['replace'](/}@@/g,_0xd5b7('0x12'))['replace'](/@{/g,'{{')[_0xd5b7('0x11')](/}@/g,'}}');var _0x593208=_0x159b97[_0xd5b7('0x16')]&&Object[_0xd5b7('0x17')](_0x159b97[_0xd5b7('0x16')])[_0xd5b7('0x18')]?'\x0a\x09'+JSON[_0xd5b7('0x19')](_0x159b97[_0xd5b7('0x16')]):'';return util[_0xd5b7('0xe')](_0xd5b7('0x1a'),moment()[_0xd5b7('0xe')]('YYYY-MM-DD\x20HH:mm:ss'),_0x159b97[_0xd5b7('0x14')][_0xd5b7('0x1b')](),_0x3862a2,_0x159b97[_0xd5b7('0x10')],_0x593208);}function consoleLogger(){var _0xbf6b62=new winston[(_0xd5b7('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xd5b7('0x1d'))][(_0xd5b7('0x1e'))]({'level':_0xd5b7('0x1f'),'json':![],'formatter':function(_0x473157){return formatter('',_0x473157);}})]});return _0xbf6b62;}function fileLogger(_0x6cf844,_0x3fe743){var _0x10c1b8=new winston[(_0xd5b7('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xd5b7('0x1d'))]['File']({'name':util['format']('%s-%s',_0x6cf844,_0xd5b7('0x20')),'filename':getLogFileName(_0x3fe743,_0x6cf844,_0xd5b7('0x20')),'level':_0xd5b7('0x20'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x2e7536){return fileFormat(_0x6cf844,_0x2e7536);}}),new winston[(_0xd5b7('0x1d'))][(_0xd5b7('0x21'))]({'name':util['format'](_0xd5b7('0x22'),_0x6cf844,debugLevel),'filename':getLogFileName(_0x3fe743,_0x6cf844,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x317583){return fileFormat(_0x6cf844,_0x317583);}}),new winston[(_0xd5b7('0x1d'))][(_0xd5b7('0x1e'))]({'level':_0xd5b7('0x1f'),'json':![],'formatter':function(_0x4961a7){return fileFormat(_0x6cf844,_0x4961a7);}})]});return _0x10c1b8;}exports['consoleLogger']=consoleLogger;exports[_0xd5b7('0x23')]=fileLogger;