Built motion from commit da617fac.|2.6.6
[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 _0x8005=['%s-%s','error','Console','consoleLogger','path','winston','../config/environment','debugLevel','toLowerCase','info','red','bold\x20yellow','white','bold\x20white','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','meta','length','stringify','transports','warn','Logger','File'];(function(_0x42676f,_0x4c3299){var _0x2b884e=function(_0x478f3f){while(--_0x478f3f){_0x42676f['push'](_0x42676f['shift']());}};_0x2b884e(++_0x4c3299);}(_0x8005,0x13f));var _0x5800=function(_0x18546c,_0x4daf94){_0x18546c=_0x18546c-0x0;var _0x46ef43=_0x8005[_0x18546c];return _0x46ef43;};'use strict';var path=require(_0x5800('0x0'));var util=require('util');var moment=require('moment');var winston=require(_0x5800('0x1'));var config=require(_0x5800('0x2'));var debugLevel=config[_0x5800('0x3')]?config[_0x5800('0x3')][_0x5800('0x4')]():_0x5800('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':'redBG\x20white','error':_0x5800('0x6'),'warn':_0x5800('0x7'),'info':_0x5800('0x8'),'print':_0x5800('0x9'),'success':'bold\x20green','http':_0x5800('0xa'),'verbose':_0x5800('0xb'),'debug':_0x5800('0xc'),'silly':'bold\x20cyan'};winston[_0x5800('0xd')](XC_LOG_COLORS);function getLogFileName(_0x57e19e,_0x1309ee,_0x57e76d){var _0x482d77=_0x57e19e||_0x5800('0xe');return path[_0x5800('0xf')](_0x482d77,util[_0x5800('0x10')]('%s-%s.log',_0x1309ee,_0x57e76d));}function formatter(_0x2ed9e2,_0x38f206){_0x38f206[_0x5800('0x11')]=_0x38f206[_0x5800('0x11')][_0x5800('0x12')](/@@{/g,_0x5800('0x13'))[_0x5800('0x12')](/}@@/g,_0x5800('0x14'))[_0x5800('0x12')](/@{/g,'{{')[_0x5800('0x12')](/}@/g,'}}');return util[_0x5800('0x10')](_0x5800('0x15'),moment()[_0x5800('0x10')](_0x5800('0x16')),_0x38f206[_0x5800('0x17')]['toUpperCase'](),_0x2ed9e2,_0x38f206['message']);}function fileFormat(_0x17f5ce,_0xb6157b){_0xb6157b[_0x5800('0x11')]=_0xb6157b[_0x5800('0x11')][_0x5800('0x12')](/@@{/g,_0x5800('0x13'))[_0x5800('0x12')](/}@@/g,'}}}')[_0x5800('0x12')](/@{/g,'{{')['replace'](/}@/g,'}}');var _0x544a69=_0xb6157b['meta']&&Object['keys'](_0xb6157b[_0x5800('0x18')])[_0x5800('0x19')]?'\x0a\x09'+JSON[_0x5800('0x1a')](_0xb6157b['meta']):'';return util['format']('[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s',moment()[_0x5800('0x10')](_0x5800('0x16')),_0xb6157b['level']['toUpperCase'](),_0x17f5ce,_0xb6157b[_0x5800('0x11')],_0x544a69);}function consoleLogger(){var _0x320f8f=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x5800('0x1b'))]['Console']({'level':_0x5800('0x1c'),'json':![],'formatter':function(_0x5e5be6){return formatter('',_0x5e5be6);}})]});return _0x320f8f;}function fileLogger(_0xefa6d8,_0x138e7b){var _0x2a5ac1=new winston[(_0x5800('0x1d'))]({'levels':XC_LOG_LEVELS,'transports':[new winston['transports'][(_0x5800('0x1e'))]({'name':util[_0x5800('0x10')](_0x5800('0x1f'),_0xefa6d8,_0x5800('0x20')),'filename':getLogFileName(_0x138e7b,_0xefa6d8,_0x5800('0x20')),'level':'error','json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x290e7c){return fileFormat(_0xefa6d8,_0x290e7c);}}),new winston[(_0x5800('0x1b'))][(_0x5800('0x1e'))]({'name':util['format'](_0x5800('0x1f'),_0xefa6d8,debugLevel),'filename':getLogFileName(_0x138e7b,_0xefa6d8,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x275c5f){return fileFormat(_0xefa6d8,_0x275c5f);}}),new winston[(_0x5800('0x1b'))][(_0x5800('0x21'))]({'level':_0x5800('0x1c'),'json':![],'formatter':function(_0xdc5ec5){return fileFormat(_0xefa6d8,_0xdc5ec5);}})]});return _0x2a5ac1;}exports[_0x5800('0x22')]=consoleLogger;exports['fileLogger']=fileLogger;