8a1a49dba5ddc14e7aa8a9256adf22a314fe644b
[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 _0x0ca2=['%s-%s','error','consoleLogger','path','util','winston','../config/environment','toLowerCase','info','redBG\x20white','red','bold\x20yellow','bold\x20green','bold\x20magenta','/var/log/xcally','join','format','%s-%s.log','message','replace','}}}','[%s]\x20[%s]\x20%s\x20-\x20%s','YYYY-MM-DD\x20HH:mm:ss','level','{{{','meta','keys','Logger','transports','Console','warn','File'];(function(_0x1527a9,_0x55feeb){var _0x15b5be=function(_0x1571d8){while(--_0x1571d8){_0x1527a9['push'](_0x1527a9['shift']());}};_0x15b5be(++_0x55feeb);}(_0x0ca2,0x183));var _0x20ca=function(_0x1764fd,_0x256895){_0x1764fd=_0x1764fd-0x0;var _0x13189e=_0x0ca2[_0x1764fd];return _0x13189e;};'use strict';var path=require(_0x20ca('0x0'));var util=require(_0x20ca('0x1'));var moment=require('moment');var winston=require(_0x20ca('0x2'));var config=require(_0x20ca('0x3'));var debugLevel=config['debugLevel']?config['debugLevel'][_0x20ca('0x4')]():_0x20ca('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':_0x20ca('0x6'),'error':_0x20ca('0x7'),'warn':_0x20ca('0x8'),'info':'white','print':'bold\x20white','success':_0x20ca('0x9'),'http':'gray','verbose':_0x20ca('0xa'),'debug':'bold\x20blue','silly':'bold\x20cyan'};winston['addColors'](XC_LOG_COLORS);function getLogFileName(_0xf272e8,_0x26cff9,_0x2d79c2){var _0x32b0ce=_0xf272e8||_0x20ca('0xb');return path[_0x20ca('0xc')](_0x32b0ce,util[_0x20ca('0xd')](_0x20ca('0xe'),_0x26cff9,_0x2d79c2));}function formatter(_0x56589e,_0x384af0){_0x384af0[_0x20ca('0xf')]=_0x384af0['message'][_0x20ca('0x10')](/@@{/g,'{{{')[_0x20ca('0x10')](/}@@/g,_0x20ca('0x11'))[_0x20ca('0x10')](/@{/g,'{{')[_0x20ca('0x10')](/}@/g,'}}');return util[_0x20ca('0xd')](_0x20ca('0x12'),moment()[_0x20ca('0xd')](_0x20ca('0x13')),_0x384af0[_0x20ca('0x14')]['toUpperCase'](),_0x56589e,_0x384af0[_0x20ca('0xf')]);}function fileFormat(_0x333463,_0x541ccb){_0x541ccb[_0x20ca('0xf')]=_0x541ccb['message'][_0x20ca('0x10')](/@@{/g,_0x20ca('0x15'))[_0x20ca('0x10')](/}@@/g,'}}}')[_0x20ca('0x10')](/@{/g,'{{')[_0x20ca('0x10')](/}@/g,'}}');var _0x3dc9f3=_0x541ccb[_0x20ca('0x16')]&&Object[_0x20ca('0x17')](_0x541ccb['meta'])['length']?'\x0a\x09'+JSON['stringify'](_0x541ccb[_0x20ca('0x16')]):'';return util[_0x20ca('0xd')]('[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s',moment()[_0x20ca('0xd')](_0x20ca('0x13')),_0x541ccb['level']['toUpperCase'](),_0x333463,_0x541ccb[_0x20ca('0xf')],_0x3dc9f3);}function consoleLogger(){var _0x2f65fc=new winston[(_0x20ca('0x18'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x20ca('0x19'))][(_0x20ca('0x1a'))]({'level':_0x20ca('0x1b'),'json':![],'formatter':function(_0x4de3e0){return formatter('',_0x4de3e0);}})]});return _0x2f65fc;}function fileLogger(_0xfd0490,_0x57d1e9){var _0x3a4a3e=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston['transports'][(_0x20ca('0x1c'))]({'name':util[_0x20ca('0xd')](_0x20ca('0x1d'),_0xfd0490,'error'),'filename':getLogFileName(_0x57d1e9,_0xfd0490,_0x20ca('0x1e')),'level':_0x20ca('0x1e'),'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x3fd240){return fileFormat(_0xfd0490,_0x3fd240);}}),new winston['transports'][(_0x20ca('0x1c'))]({'name':util['format'](_0x20ca('0x1d'),_0xfd0490,debugLevel),'filename':getLogFileName(_0x57d1e9,_0xfd0490,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x32ed14){return fileFormat(_0xfd0490,_0x32ed14);}}),new winston[(_0x20ca('0x19'))][(_0x20ca('0x1a'))]({'level':'warn','json':![],'formatter':function(_0x5217a7){return fileFormat(_0xfd0490,_0x5217a7);}})]});return _0x3a4a3e;}exports[_0x20ca('0x1f')]=consoleLogger;exports['fileLogger']=fileLogger;