Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / utils / client-side-logger.js
index 9458494..b0a5689 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6b66=['inspect','use','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s','agent_id','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s\x20(id=%s\x20name=%s)','x-forwarded-for','name','device','other','agent_name','test','setupLoggers','fs-extra','lodash','express-winston','path','./loggers','fileLogger','safeTemplate','./mask-sensitive-data','maskSensitiveData','join','/var','log','xcally','client','catch','user','then','data','api','auth','set','client-side-logger','isEmpty','body','format','method','headers','connection','remoteAddress','statusCode','responseTime','role'];(function(_0x4d08b8,_0x34c445){var _0x70214a=function(_0x4db67c){while(--_0x4db67c){_0x4d08b8['push'](_0x4d08b8['shift']());}};_0x70214a(++_0x34c445);}(_0x6b66,0x16c));var _0x66b6=function(_0x118835,_0x5002cf){_0x118835=_0x118835-0x0;var _0x4f1c6a=_0x6b66[_0x118835];return _0x4f1c6a;};var fs=require(_0x66b6('0x0'));var _=require(_0x66b6('0x1'));var ewinston=require(_0x66b6('0x2'));var path=require(_0x66b6('0x3'));var util=require('util');var fileLogger=require(_0x66b6('0x4'))[_0x66b6('0x5')];var safeTemplate=require('./safe-template')[_0x66b6('0x6')];var maskSensitiveData=require(_0x66b6('0x7'))[_0x66b6('0x8')];function ClientSideLogger(){function _0x2cb5b5(_0xee85bb){var _0x45ddda=path[_0x66b6('0x9')](_0x66b6('0xa'),_0x66b6('0xb'),_0x66b6('0xc'));var _0x41e9fc=path[_0x66b6('0x9')](_0x66b6('0xd'),_0xee85bb['role']+'-'+_0xee85bb['name']);return fs['ensureDir'](path[_0x66b6('0x9')](_0x45ddda,_0x41e9fc))['then'](function(){var _0x95de60=fileLogger(_0x66b6('0xd'),path[_0x66b6('0x9')](_0x45ddda,_0x41e9fc));return _0x95de60;})[_0x66b6('0xe')](function(_0x588472){throw _0x588472;});}this[_0x66b6('0xb')]=function(_0x719834,_0x27e9eb,_0x51bcf3,_0x15bdfa){return _0x2cb5b5(_0x719834[_0x66b6('0xf')])['then'](function(_0x35a880){var _0x50443e=_0x35a880[_0x27e9eb];return _0x50443e;})[_0x66b6('0x10')](function(_0x2bfac7){var _0x315b8f=_0x719834[_0x66b6('0xf')]?_0x719834[_0x66b6('0xf')]['id']:'no-user';var _0x1b89f1=_0x15bdfa[_0x66b6('0x11')];var _0x2fc69e=_0x15bdfa['timestamp'];var _0x517d1a=new Date(Number(_0x2fc69e));return _0x2bfac7(_0x315b8f,_0x517d1a,_0x51bcf3,_0x1b89f1);})['catch'](function(_0x3750b0){fileLogger(_0x66b6('0xd'))['error'](_0x3750b0);});};}function setupLoggers(_0x908716){return new Promise(function(_0x2aaf8f){var _0x2bad6a=new ClientSideLogger();var _0x4268b7=fileLogger(_0x66b6('0x12'));var _0x4c60fb=fileLogger(_0x66b6('0x13'));_0x908716[_0x66b6('0x14')](_0x66b6('0x15'),_0x2bad6a);_0x908716['use'](ewinston['logger']({'winstonInstance':_0x4268b7,'meta':![],'statusLevels':!![],'msg':function(_0x3bf93d,_0x4ff5cc){var _0x5592='%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s';if(!_[_0x66b6('0x16')](_0x3bf93d[_0x66b6('0x17')])){_0x5592+='\x20body=%s';var _0x56ae71=_0x3bf93d[_0x66b6('0x17')];maskSensitiveData(_0x56ae71);}return safeTemplate(util[_0x66b6('0x18')](_0x5592,_0x3bf93d[_0x66b6('0x19')],_0x3bf93d['headers']['x-forwarded-for']?_0x3bf93d[_0x66b6('0x1a')]['x-forwarded-for']:_0x3bf93d[_0x66b6('0x1b')][_0x66b6('0x1c')]||_0x3bf93d['ip'],_0x3bf93d['url'],_0x4ff5cc[_0x66b6('0x1d')],_0x4ff5cc[_0x66b6('0x1e')],_0x3bf93d[_0x66b6('0xf')]?_0x3bf93d[_0x66b6('0xf')]['id']:null,_0x3bf93d[_0x66b6('0xf')]?_0x3bf93d[_0x66b6('0xf')]['name']:null,_0x3bf93d['user']?_0x3bf93d['user'][_0x66b6('0x1f')]:null,_0x56ae71?util[_0x66b6('0x20')](_0x56ae71,![],null):''));}}));_0x908716[_0x66b6('0x21')](ewinston['logger']({'winstonInstance':_0x4c60fb,'meta':![],'statusLevels':!![],'msg':function(_0x2af2c4,_0x167300){var _0x70126d=_0x66b6('0x22');if(_0x2af2c4[_0x66b6('0x17')]&&_0x2af2c4[_0x66b6('0x17')]['device']&&_0x2af2c4[_0x66b6('0x17')][_0x66b6('0x23')]){_0x70126d=_0x66b6('0x24');}return util[_0x66b6('0x18')](_0x70126d,_0x2af2c4['method'],_0x2af2c4[_0x66b6('0x1a')]['x-forwarded-for']?_0x2af2c4[_0x66b6('0x1a')][_0x66b6('0x25')]:_0x2af2c4['connection']['remoteAddress']||_0x2af2c4['ip'],_0x2af2c4['url'],_0x167300[_0x66b6('0x1d')],_0x167300[_0x66b6('0x1e')],_0x2af2c4[_0x66b6('0xf')]?_0x2af2c4['user']['id']:null,_0x2af2c4[_0x66b6('0xf')]?_0x2af2c4[_0x66b6('0xf')][_0x66b6('0x26')]:null,_0x2af2c4[_0x66b6('0xf')]?_0x2af2c4[_0x66b6('0xf')][_0x66b6('0x1f')]:null,_0x2af2c4[_0x66b6('0x17')]&&_0x2af2c4['body'][_0x66b6('0x27')]?_0x2af2c4[_0x66b6('0x17')][_0x66b6('0x27')]:_0x66b6('0x28'),_0x2af2c4[_0x66b6('0x17')]&&_0x2af2c4[_0x66b6('0x17')][_0x66b6('0x23')]?_0x2af2c4[_0x66b6('0x17')][_0x66b6('0x23')]:'',_0x2af2c4[_0x66b6('0x17')]&&_0x2af2c4[_0x66b6('0x17')][_0x66b6('0x29')]?_0x2af2c4[_0x66b6('0x17')][_0x66b6('0x29')]:'');},'ignoreRoute':function(_0x80cd66){var _0x2501c9=/\/api\/users\/[0-9]+\/(login|logout)/gi;return!_0x2501c9[_0x66b6('0x2a')](_0x80cd66['url']);}}));return _0x2aaf8f();});}exports[_0x66b6('0x2b')]=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