c7cf817452729e600684d3e86435d0780ec8824b
[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 _0x80ea=['addColors','/var/log/xcally','format','%s-%s.log','message','replace','{{{','[%s]\x20[%s]\x20%s\x20-\x20%s','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','}}}','meta','keys','length','stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','Logger','transports','warn','File','%s-%s','error','consoleLogger','fileLogger','path','util','winston','../config/environment','toLowerCase','info','bold\x20yellow','gray','bold\x20magenta'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x80ea,0x1d3));var _0xa80e=function(_0x383bc8,_0x1939d3){_0x383bc8=_0x383bc8-0x0;var _0x4f4f71=_0x80ea[_0x383bc8];return _0x4f4f71;};'use strict';var path=require(_0xa80e('0x0'));var util=require(_0xa80e('0x1'));var moment=require('moment');var winston=require(_0xa80e('0x2'));var config=require(_0xa80e('0x3'));var debugLevel=config['debugLevel']?config['debugLevel'][_0xa80e('0x4')]():_0xa80e('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':'red','warn':_0xa80e('0x6'),'info':'white','print':'bold\x20white','success':'bold\x20green','http':_0xa80e('0x7'),'verbose':_0xa80e('0x8'),'debug':'bold\x20blue','silly':'bold\x20cyan'};winston[_0xa80e('0x9')](XC_LOG_COLORS);function getLogFileName(_0x4b4d47,_0x4fc699,_0x23613a){var _0x263447=_0x4b4d47||_0xa80e('0xa');return path['join'](_0x263447,util[_0xa80e('0xb')](_0xa80e('0xc'),_0x4fc699,_0x23613a));}function formatter(_0x51f807,_0x538832){_0x538832['message']=_0x538832[_0xa80e('0xd')][_0xa80e('0xe')](/@@{/g,_0xa80e('0xf'))[_0xa80e('0xe')](/}@@/g,'}}}')[_0xa80e('0xe')](/@{/g,'{{')['replace'](/}@/g,'}}');return util[_0xa80e('0xb')](_0xa80e('0x10'),moment()[_0xa80e('0xb')](_0xa80e('0x11')),_0x538832[_0xa80e('0x12')][_0xa80e('0x13')](),_0x51f807,_0x538832[_0xa80e('0xd')]);}function fileFormat(_0x3a9f24,_0x180b51){_0x180b51[_0xa80e('0xd')]=_0x180b51[_0xa80e('0xd')][_0xa80e('0xe')](/@@{/g,_0xa80e('0xf'))[_0xa80e('0xe')](/}@@/g,_0xa80e('0x14'))[_0xa80e('0xe')](/@{/g,'{{')[_0xa80e('0xe')](/}@/g,'}}');var _0x151391=_0x180b51[_0xa80e('0x15')]&&Object[_0xa80e('0x16')](_0x180b51['meta'])[_0xa80e('0x17')]?'\x0a\x09'+JSON[_0xa80e('0x18')](_0x180b51[_0xa80e('0x15')]):'';return util[_0xa80e('0xb')](_0xa80e('0x19'),moment()[_0xa80e('0xb')]('YYYY-MM-DD\x20HH:mm:ss'),_0x180b51[_0xa80e('0x12')][_0xa80e('0x13')](),_0x3a9f24,_0x180b51[_0xa80e('0xd')],_0x151391);}function consoleLogger(){var _0x24d795=new winston[(_0xa80e('0x1a'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xa80e('0x1b'))]['Console']({'level':_0xa80e('0x1c'),'json':![],'formatter':function(_0x3eca82){return formatter('',_0x3eca82);}})]});return _0x24d795;}function fileLogger(_0x2dad34,_0x2acb31){var _0x110aeb=new winston[(_0xa80e('0x1a'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xa80e('0x1b'))][(_0xa80e('0x1d'))]({'name':util['format'](_0xa80e('0x1e'),_0x2dad34,_0xa80e('0x1f')),'filename':getLogFileName(_0x2acb31,_0x2dad34,_0xa80e('0x1f')),'level':_0xa80e('0x1f'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x4ff5e6){return fileFormat(_0x2dad34,_0x4ff5e6);}}),new winston[(_0xa80e('0x1b'))]['File']({'name':util[_0xa80e('0xb')](_0xa80e('0x1e'),_0x2dad34,debugLevel),'filename':getLogFileName(_0x2acb31,_0x2dad34,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x2043d3){return fileFormat(_0x2dad34,_0x2043d3);}}),new winston['transports']['Console']({'level':_0xa80e('0x1c'),'json':![],'formatter':function(_0x3bf9ab){return fileFormat(_0x2dad34,_0x3bf9ab);}})]});return _0x110aeb;}exports[_0xa80e('0x20')]=consoleLogger;exports[_0xa80e('0x21')]=fileLogger;