f8af8757040ee7a62c5d0acf12bf9d456d63f816
[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 _0xa841=['File','%s-%s','error','Console','fileLogger','path','util','moment','winston','debugLevel','toLowerCase','info','redBG\x20white','bold\x20yellow','bold\x20green','gray','bold\x20magenta','bold\x20cyan','addColors','/var/log/xcally','message','{{{','replace','}}}','[%s]\x20[%s]\x20%s\x20-\x20%s','format','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','keys','meta','length','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','Logger','transports','warn'];(function(_0x38325d,_0x3a6616){var _0x2cd93c=function(_0xf7e06d){while(--_0xf7e06d){_0x38325d['push'](_0x38325d['shift']());}};_0x2cd93c(++_0x3a6616);}(_0xa841,0x16d));var _0x1a84=function(_0x4e676e,_0x2a7c6d){_0x4e676e=_0x4e676e-0x0;var _0x336a3c=_0xa841[_0x4e676e];return _0x336a3c;};'use strict';var path=require(_0x1a84('0x0'));var util=require(_0x1a84('0x1'));var moment=require(_0x1a84('0x2'));var winston=require(_0x1a84('0x3'));var config=require('../config/environment');var debugLevel=config[_0x1a84('0x4')]?config[_0x1a84('0x4')][_0x1a84('0x5')]():_0x1a84('0x6');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':_0x1a84('0x7'),'error':'red','warn':_0x1a84('0x8'),'info':'white','print':'bold\x20white','success':_0x1a84('0x9'),'http':_0x1a84('0xa'),'verbose':_0x1a84('0xb'),'debug':'bold\x20blue','silly':_0x1a84('0xc')};winston[_0x1a84('0xd')](XC_LOG_COLORS);function getLogFileName(_0x22a46c,_0x4c5b04,_0xea056b){var _0x5e27c4=_0x22a46c||_0x1a84('0xe');return path['join'](_0x5e27c4,util['format']('%s-%s.log',_0x4c5b04,_0xea056b));}function formatter(_0x20db94,_0x11b1eb){_0x11b1eb[_0x1a84('0xf')]=_0x11b1eb[_0x1a84('0xf')]['replace'](/@@{/g,_0x1a84('0x10'))[_0x1a84('0x11')](/}@@/g,_0x1a84('0x12'))[_0x1a84('0x11')](/@{/g,'{{')[_0x1a84('0x11')](/}@/g,'}}');return util['format'](_0x1a84('0x13'),moment()[_0x1a84('0x14')](_0x1a84('0x15')),_0x11b1eb[_0x1a84('0x16')][_0x1a84('0x17')](),_0x20db94,_0x11b1eb[_0x1a84('0xf')]);}function fileFormat(_0x19d1c4,_0x4c6fbb){_0x4c6fbb[_0x1a84('0xf')]=_0x4c6fbb['message']['replace'](/@@{/g,'{{{')[_0x1a84('0x11')](/}@@/g,_0x1a84('0x12'))[_0x1a84('0x11')](/@{/g,'{{')[_0x1a84('0x11')](/}@/g,'}}');var _0x33f356=_0x4c6fbb['meta']&&Object[_0x1a84('0x18')](_0x4c6fbb[_0x1a84('0x19')])[_0x1a84('0x1a')]?'\x0a\x09'+JSON['stringify'](_0x4c6fbb[_0x1a84('0x19')]):'';return util['format'](_0x1a84('0x1b'),moment()[_0x1a84('0x14')]('YYYY-MM-DD\x20HH:mm:ss'),_0x4c6fbb[_0x1a84('0x16')]['toUpperCase'](),_0x19d1c4,_0x4c6fbb[_0x1a84('0xf')],_0x33f356);}function consoleLogger(){var _0x5f0acc=new winston[(_0x1a84('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x1a84('0x1d'))]['Console']({'level':_0x1a84('0x1e'),'json':![],'formatter':function(_0x2057a3){return formatter('',_0x2057a3);}})]});return _0x5f0acc;}function fileLogger(_0x3ee9e1,_0x5a604e){var _0x3fad08=new winston[(_0x1a84('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0x1a84('0x1d'))][(_0x1a84('0x1f'))]({'name':util['format'](_0x1a84('0x20'),_0x3ee9e1,_0x1a84('0x21')),'filename':getLogFileName(_0x5a604e,_0x3ee9e1,'error'),'level':'error','json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x5f13b4){return fileFormat(_0x3ee9e1,_0x5f13b4);}}),new winston[(_0x1a84('0x1d'))][(_0x1a84('0x1f'))]({'name':util[_0x1a84('0x14')](_0x1a84('0x20'),_0x3ee9e1,debugLevel),'filename':getLogFileName(_0x5a604e,_0x3ee9e1,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x2b91c1){return fileFormat(_0x3ee9e1,_0x2b91c1);}}),new winston[(_0x1a84('0x1d'))][(_0x1a84('0x22'))]({'level':_0x1a84('0x1e'),'json':![],'formatter':function(_0x368902){return fileFormat(_0x3ee9e1,_0x368902);}})]});return _0x3fad08;}exports['consoleLogger']=consoleLogger;exports[_0x1a84('0x23')]=fileLogger;