Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / utils / client-side-logger.js
index f012d51..b0a5689 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf85b=['role','name','ensureDir','then','catch','user','timestamp','error','api','auth','use','logger','isEmpty','body','\x20body=%s','format','method','headers','x-forwarded-for','url','statusCode','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s','device','agent_id','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s\x20(id=%s\x20name=%s)','connection','remoteAddress','responseTime','other','agent_name','test','setupLoggers','fs-extra','lodash','path','util','fileLogger','./safe-template','join','/var','log','client'];(function(_0x43edf6,_0x4e5fe){var _0x5d813a=function(_0x55b08a){while(--_0x55b08a){_0x43edf6['push'](_0x43edf6['shift']());}};_0x5d813a(++_0x4e5fe);}(_0xf85b,0xf2));var _0xbf85=function(_0x564308,_0x3eb3bd){_0x564308=_0x564308-0x0;var _0x5a9cae=_0xf85b[_0x564308];return _0x5a9cae;};var fs=require(_0xbf85('0x0'));var _=require(_0xbf85('0x1'));var ewinston=require('express-winston');var path=require(_0xbf85('0x2'));var util=require(_0xbf85('0x3'));var fileLogger=require('./loggers')[_0xbf85('0x4')];var safeTemplate=require(_0xbf85('0x5'))['safeTemplate'];var maskSensitiveData=require('./mask-sensitive-data')['maskSensitiveData'];function ClientSideLogger(){function _0x30d866(_0x8a2b02){var _0x24d87d=path[_0xbf85('0x6')](_0xbf85('0x7'),_0xbf85('0x8'),'xcally');var _0x58bd8b=path[_0xbf85('0x6')](_0xbf85('0x9'),_0x8a2b02[_0xbf85('0xa')]+'-'+_0x8a2b02[_0xbf85('0xb')]);return fs[_0xbf85('0xc')](path['join'](_0x24d87d,_0x58bd8b))[_0xbf85('0xd')](function(){var _0x58f087=fileLogger('client',path[_0xbf85('0x6')](_0x24d87d,_0x58bd8b));return _0x58f087;})[_0xbf85('0xe')](function(_0x4821a1){throw _0x4821a1;});}this[_0xbf85('0x8')]=function(_0x11bb34,_0x45914b,_0x11eb64,_0x39da65){return _0x30d866(_0x11bb34[_0xbf85('0xf')])['then'](function(_0x2513df){var _0x26942c=_0x2513df[_0x45914b];return _0x26942c;})[_0xbf85('0xd')](function(_0x402bc5){var _0x599c72=_0x11bb34[_0xbf85('0xf')]?_0x11bb34['user']['id']:'no-user';var _0xdcd620=_0x39da65['data'];var _0x5aa863=_0x39da65[_0xbf85('0x10')];var _0x507fe4=new Date(Number(_0x5aa863));return _0x402bc5(_0x599c72,_0x507fe4,_0x11eb64,_0xdcd620);})[_0xbf85('0xe')](function(_0x38e844){fileLogger(_0xbf85('0x9'))[_0xbf85('0x11')](_0x38e844);});};}function setupLoggers(_0x37ef3d){return new Promise(function(_0xe8feaa){var _0x230bb9=new ClientSideLogger();var _0x4813be=fileLogger(_0xbf85('0x12'));var _0x32063e=fileLogger(_0xbf85('0x13'));_0x37ef3d['set']('client-side-logger',_0x230bb9);_0x37ef3d[_0xbf85('0x14')](ewinston[_0xbf85('0x15')]({'winstonInstance':_0x4813be,'meta':![],'statusLevels':!![],'msg':function(_0x59aa32,_0x59c38a){var _0x3c8353='%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s';if(!_[_0xbf85('0x16')](_0x59aa32[_0xbf85('0x17')])){_0x3c8353+=_0xbf85('0x18');var _0x250db8=_0x59aa32[_0xbf85('0x17')];maskSensitiveData(_0x250db8);}return safeTemplate(util[_0xbf85('0x19')](_0x3c8353,_0x59aa32[_0xbf85('0x1a')],_0x59aa32[_0xbf85('0x1b')]['x-forwarded-for']?_0x59aa32[_0xbf85('0x1b')][_0xbf85('0x1c')]:_0x59aa32['connection']['remoteAddress']||_0x59aa32['ip'],_0x59aa32[_0xbf85('0x1d')],_0x59c38a[_0xbf85('0x1e')],_0x59c38a['responseTime'],_0x59aa32[_0xbf85('0xf')]?_0x59aa32['user']['id']:null,_0x59aa32[_0xbf85('0xf')]?_0x59aa32[_0xbf85('0xf')][_0xbf85('0xb')]:null,_0x59aa32['user']?_0x59aa32[_0xbf85('0xf')]['role']:null,_0x250db8?util['inspect'](_0x250db8,![],null):''));}}));_0x37ef3d[_0xbf85('0x14')](ewinston[_0xbf85('0x15')]({'winstonInstance':_0x32063e,'meta':![],'statusLevels':!![],'msg':function(_0x16991a,_0xcf96d7){var _0x1ea468=_0xbf85('0x1f');if(_0x16991a[_0xbf85('0x17')]&&_0x16991a[_0xbf85('0x17')][_0xbf85('0x20')]&&_0x16991a[_0xbf85('0x17')][_0xbf85('0x21')]){_0x1ea468=_0xbf85('0x22');}return util[_0xbf85('0x19')](_0x1ea468,_0x16991a['method'],_0x16991a['headers'][_0xbf85('0x1c')]?_0x16991a['headers'][_0xbf85('0x1c')]:_0x16991a[_0xbf85('0x23')][_0xbf85('0x24')]||_0x16991a['ip'],_0x16991a[_0xbf85('0x1d')],_0xcf96d7[_0xbf85('0x1e')],_0xcf96d7[_0xbf85('0x25')],_0x16991a['user']?_0x16991a[_0xbf85('0xf')]['id']:null,_0x16991a[_0xbf85('0xf')]?_0x16991a['user']['name']:null,_0x16991a['user']?_0x16991a[_0xbf85('0xf')][_0xbf85('0xa')]:null,_0x16991a[_0xbf85('0x17')]&&_0x16991a[_0xbf85('0x17')][_0xbf85('0x20')]?_0x16991a[_0xbf85('0x17')][_0xbf85('0x20')]:_0xbf85('0x26'),_0x16991a[_0xbf85('0x17')]&&_0x16991a[_0xbf85('0x17')][_0xbf85('0x21')]?_0x16991a['body']['agent_id']:'',_0x16991a['body']&&_0x16991a[_0xbf85('0x17')][_0xbf85('0x27')]?_0x16991a['body'][_0xbf85('0x27')]:'');},'ignoreRoute':function(_0x5ea02a){var _0x80c2ee=/\/api\/users\/[0-9]+\/(login|logout)/gi;return!_0x80c2ee[_0xbf85('0x28')](_0x5ea02a[_0xbf85('0x1d')]);}}));return _0xe8feaa();});}exports[_0xbf85('0x29')]=setupLoggers;
\ No newline at end of file
+var _0x37a6=['remoteAddress','url','statusCode','responseTime','use','logger','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s','device','agent_id','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s\x20(id=%s\x20name=%s)','method','other','agent_name','test','setupLoggers','fs-extra','lodash','express-winston','util','./loggers','./safe-template','safeTemplate','./mask-sensitive-data','maskSensitiveData','join','/var','log','client','role','name','ensureDir','user','no-user','data','timestamp','catch','error','api','auth','set','client-side-logger','body','\x20body=%s','format','headers','x-forwarded-for','connection'];(function(_0x2dc343,_0xf015a2){var _0x51eac5=function(_0x1adfef){while(--_0x1adfef){_0x2dc343['push'](_0x2dc343['shift']());}};_0x51eac5(++_0xf015a2);}(_0x37a6,0xfa));var _0x637a=function(_0x4b3637,_0x3657ea){_0x4b3637=_0x4b3637-0x0;var _0x2fcb89=_0x37a6[_0x4b3637];return _0x2fcb89;};var fs=require(_0x637a('0x0'));var _=require(_0x637a('0x1'));var ewinston=require(_0x637a('0x2'));var path=require('path');var util=require(_0x637a('0x3'));var fileLogger=require(_0x637a('0x4'))['fileLogger'];var safeTemplate=require(_0x637a('0x5'))[_0x637a('0x6')];var maskSensitiveData=require(_0x637a('0x7'))[_0x637a('0x8')];function ClientSideLogger(){function _0x470508(_0x4ee53c){var _0x47d4aa=path[_0x637a('0x9')](_0x637a('0xa'),_0x637a('0xb'),'xcally');var _0x2ec776=path[_0x637a('0x9')](_0x637a('0xc'),_0x4ee53c[_0x637a('0xd')]+'-'+_0x4ee53c[_0x637a('0xe')]);return fs[_0x637a('0xf')](path[_0x637a('0x9')](_0x47d4aa,_0x2ec776))['then'](function(){var _0x5d5f23=fileLogger(_0x637a('0xc'),path[_0x637a('0x9')](_0x47d4aa,_0x2ec776));return _0x5d5f23;})['catch'](function(_0x2c1622){throw _0x2c1622;});}this[_0x637a('0xb')]=function(_0x4bb919,_0x4ecffc,_0x5bf12e,_0x5e1430){return _0x470508(_0x4bb919[_0x637a('0x10')])['then'](function(_0x81c71d){var _0x1b1211=_0x81c71d[_0x4ecffc];return _0x1b1211;})['then'](function(_0x373ce0){var _0x42fa9a=_0x4bb919[_0x637a('0x10')]?_0x4bb919[_0x637a('0x10')]['id']:_0x637a('0x11');var _0x2ca626=_0x5e1430[_0x637a('0x12')];var _0x46ac18=_0x5e1430[_0x637a('0x13')];var _0x5cfcb4=new Date(Number(_0x46ac18));return _0x373ce0(_0x42fa9a,_0x5cfcb4,_0x5bf12e,_0x2ca626);})[_0x637a('0x14')](function(_0x3ac7af){fileLogger(_0x637a('0xc'))[_0x637a('0x15')](_0x3ac7af);});};}function setupLoggers(_0x3fb7b2){return new Promise(function(_0x2c2e3c){var _0x309b0a=new ClientSideLogger();var _0x3ed6a7=fileLogger(_0x637a('0x16'));var _0x5d81f=fileLogger(_0x637a('0x17'));_0x3fb7b2[_0x637a('0x18')](_0x637a('0x19'),_0x309b0a);_0x3fb7b2['use'](ewinston['logger']({'winstonInstance':_0x3ed6a7,'meta':![],'statusLevels':!![],'msg':function(_0xc55cc2,_0x2e927d){var _0x22efec='%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s';if(!_['isEmpty'](_0xc55cc2[_0x637a('0x1a')])){_0x22efec+=_0x637a('0x1b');var _0x3cacef=_0xc55cc2[_0x637a('0x1a')];maskSensitiveData(_0x3cacef);}return safeTemplate(util[_0x637a('0x1c')](_0x22efec,_0xc55cc2['method'],_0xc55cc2[_0x637a('0x1d')]['x-forwarded-for']?_0xc55cc2[_0x637a('0x1d')][_0x637a('0x1e')]:_0xc55cc2[_0x637a('0x1f')][_0x637a('0x20')]||_0xc55cc2['ip'],_0xc55cc2[_0x637a('0x21')],_0x2e927d[_0x637a('0x22')],_0x2e927d[_0x637a('0x23')],_0xc55cc2[_0x637a('0x10')]?_0xc55cc2[_0x637a('0x10')]['id']:null,_0xc55cc2[_0x637a('0x10')]?_0xc55cc2['user'][_0x637a('0xe')]:null,_0xc55cc2['user']?_0xc55cc2[_0x637a('0x10')][_0x637a('0xd')]:null,_0x3cacef?util['inspect'](_0x3cacef,![],null):''));}}));_0x3fb7b2[_0x637a('0x24')](ewinston[_0x637a('0x25')]({'winstonInstance':_0x5d81f,'meta':![],'statusLevels':!![],'msg':function(_0x3e147f,_0x5ca078){var _0x322970=_0x637a('0x26');if(_0x3e147f[_0x637a('0x1a')]&&_0x3e147f[_0x637a('0x1a')][_0x637a('0x27')]&&_0x3e147f[_0x637a('0x1a')][_0x637a('0x28')]){_0x322970=_0x637a('0x29');}return util[_0x637a('0x1c')](_0x322970,_0x3e147f[_0x637a('0x2a')],_0x3e147f['headers']['x-forwarded-for']?_0x3e147f['headers'][_0x637a('0x1e')]:_0x3e147f[_0x637a('0x1f')][_0x637a('0x20')]||_0x3e147f['ip'],_0x3e147f[_0x637a('0x21')],_0x5ca078[_0x637a('0x22')],_0x5ca078[_0x637a('0x23')],_0x3e147f['user']?_0x3e147f[_0x637a('0x10')]['id']:null,_0x3e147f['user']?_0x3e147f[_0x637a('0x10')][_0x637a('0xe')]:null,_0x3e147f[_0x637a('0x10')]?_0x3e147f[_0x637a('0x10')]['role']:null,_0x3e147f['body']&&_0x3e147f[_0x637a('0x1a')][_0x637a('0x27')]?_0x3e147f[_0x637a('0x1a')]['device']:_0x637a('0x2b'),_0x3e147f['body']&&_0x3e147f['body'][_0x637a('0x28')]?_0x3e147f['body'][_0x637a('0x28')]:'',_0x3e147f[_0x637a('0x1a')]&&_0x3e147f[_0x637a('0x1a')][_0x637a('0x2c')]?_0x3e147f['body'][_0x637a('0x2c')]:'');},'ignoreRoute':function(_0xabde1){var _0xca5f37=/\/api\/users\/[0-9]+\/(login|logout)/gi;return!_0xca5f37[_0x637a('0x2d')](_0xabde1['url']);}}));return _0x2c2e3c();});}exports[_0x637a('0x2e')]=setupLoggers;
\ No newline at end of file