Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / utils / client-side-logger.js
index 94c3596..f3a7614 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x25d1=['data','timestamp','api','auth','set','use','logger','body','\x20body=%s','format','method','headers','x-forwarded-for','connection','remoteAddress','url','statusCode','responseTime','role','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)','other','agent_name','setupLoggers','lodash','path','util','./loggers','./safe-template','safeTemplate','./mask-sensitive-data','maskSensitiveData','join','/var','log','xcally','client','name','user','then','no-user'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x25d1,0x6d));var _0x125d=function(_0x1e9dcc,_0x461662){_0x1e9dcc=_0x1e9dcc-0x0;var _0x49637d=_0x25d1[_0x1e9dcc];return _0x49637d;};var fs=require('fs-extra');var _=require(_0x125d('0x0'));var ewinston=require('express-winston');var path=require(_0x125d('0x1'));var util=require(_0x125d('0x2'));var fileLogger=require(_0x125d('0x3'))['fileLogger'];var safeTemplate=require(_0x125d('0x4'))[_0x125d('0x5')];var maskSensitiveData=require(_0x125d('0x6'))[_0x125d('0x7')];function ClientSideLogger(){function _0x2c5371(_0x1f9b8c){var _0x1fe204=path[_0x125d('0x8')](_0x125d('0x9'),_0x125d('0xa'),_0x125d('0xb'));var _0x473de4=path[_0x125d('0x8')](_0x125d('0xc'),_0x1f9b8c['role']+'-'+_0x1f9b8c[_0x125d('0xd')]);return fs['ensureDir'](path['join'](_0x1fe204,_0x473de4))['then'](function(){var _0x244f6b=fileLogger(_0x125d('0xc'),path[_0x125d('0x8')](_0x1fe204,_0x473de4));return _0x244f6b;})['catch'](function(_0x1a0729){throw _0x1a0729;});}this['log']=function(_0x1a6de3,_0x407607,_0x30165a,_0x620c60){return _0x2c5371(_0x1a6de3[_0x125d('0xe')])[_0x125d('0xf')](function(_0x1c0931){var _0x567a14=_0x1c0931[_0x407607];return _0x567a14;})[_0x125d('0xf')](function(_0x59e6e0){var _0x5330d8=_0x1a6de3['user']?_0x1a6de3[_0x125d('0xe')]['id']:_0x125d('0x10');var _0x35ed55=_0x620c60[_0x125d('0x11')];var _0x4c4d1d=_0x620c60[_0x125d('0x12')];var _0x18ec45=new Date(Number(_0x4c4d1d));return _0x59e6e0(_0x5330d8,_0x18ec45,_0x30165a,_0x35ed55);})['catch'](function(_0x5ae25d){fileLogger(_0x125d('0xc'))['error'](_0x5ae25d);});};}function setupLoggers(_0x4a072e){return new Promise(function(_0x21cd03){var _0x55501d=new ClientSideLogger();var _0x50b535=fileLogger(_0x125d('0x13'));var _0x5e9bf6=fileLogger(_0x125d('0x14'));_0x4a072e[_0x125d('0x15')]('client-side-logger',_0x55501d);_0x4a072e[_0x125d('0x16')](ewinston[_0x125d('0x17')]({'winstonInstance':_0x50b535,'meta':![],'statusLevels':!![],'msg':function(_0x12307f,_0x1de4ff){var _0x4ca998='%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s';if(!_['isEmpty'](_0x12307f[_0x125d('0x18')])){_0x4ca998+=_0x125d('0x19');var _0xedc87c=_0x12307f[_0x125d('0x18')];maskSensitiveData(_0xedc87c);}return safeTemplate(util[_0x125d('0x1a')](_0x4ca998,_0x12307f[_0x125d('0x1b')],_0x12307f[_0x125d('0x1c')][_0x125d('0x1d')]?_0x12307f[_0x125d('0x1c')][_0x125d('0x1d')]:_0x12307f[_0x125d('0x1e')][_0x125d('0x1f')]||_0x12307f['ip'],_0x12307f[_0x125d('0x20')],_0x1de4ff[_0x125d('0x21')],_0x1de4ff[_0x125d('0x22')],_0x12307f['user']?_0x12307f[_0x125d('0xe')]['id']:null,_0x12307f[_0x125d('0xe')]?_0x12307f['user'][_0x125d('0xd')]:null,_0x12307f[_0x125d('0xe')]?_0x12307f[_0x125d('0xe')][_0x125d('0x23')]:null,_0xedc87c?util['inspect'](_0xedc87c,![],null):''));}}));_0x4a072e[_0x125d('0x16')](ewinston[_0x125d('0x17')]({'winstonInstance':_0x5e9bf6,'meta':![],'statusLevels':!![],'msg':function(_0x410036,_0x38f77d){var _0x35951f='%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s';if(_0x410036[_0x125d('0x18')]&&_0x410036[_0x125d('0x18')][_0x125d('0x24')]&&_0x410036['body'][_0x125d('0x25')]){_0x35951f=_0x125d('0x26');}return util[_0x125d('0x1a')](_0x35951f,_0x410036[_0x125d('0x1b')],_0x410036['headers'][_0x125d('0x1d')]?_0x410036['headers']['x-forwarded-for']:_0x410036[_0x125d('0x1e')][_0x125d('0x1f')]||_0x410036['ip'],_0x410036['url'],_0x38f77d[_0x125d('0x21')],_0x38f77d[_0x125d('0x22')],_0x410036[_0x125d('0xe')]?_0x410036[_0x125d('0xe')]['id']:null,_0x410036[_0x125d('0xe')]?_0x410036[_0x125d('0xe')]['name']:null,_0x410036['user']?_0x410036[_0x125d('0xe')][_0x125d('0x23')]:null,_0x410036[_0x125d('0x18')]&&_0x410036[_0x125d('0x18')][_0x125d('0x24')]?_0x410036[_0x125d('0x18')][_0x125d('0x24')]:_0x125d('0x27'),_0x410036[_0x125d('0x18')]&&_0x410036['body'][_0x125d('0x25')]?_0x410036['body'][_0x125d('0x25')]:'',_0x410036[_0x125d('0x18')]&&_0x410036[_0x125d('0x18')][_0x125d('0x28')]?_0x410036[_0x125d('0x18')][_0x125d('0x28')]:'');},'ignoreRoute':function(_0x360689){var _0x1171d2=/\/api\/users\/[0-9]+\/(login|logout)/gi;return!_0x1171d2['test'](_0x360689[_0x125d('0x20')]);}}));return _0x21cd03();});}exports[_0x125d('0x29')]=setupLoggers;
\ No newline at end of file
+var _0x0e59=['timestamp','error','api','auth','set','client-side-logger','use','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s','isEmpty','body','\x20body=%s','format','method','headers','x-forwarded-for','connection','remoteAddress','statusCode','responseTime','logger','device','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s\x20(id=%s\x20name=%s)','url','other','agent_id','agent_name','test','setupLoggers','fs-extra','lodash','express-winston','util','fileLogger','./safe-template','safeTemplate','./mask-sensitive-data','/var','log','xcally','client','role','name','ensureDir','join','then','catch','user','data'];(function(_0x557701,_0x180f95){var _0x4c6d09=function(_0x241b67){while(--_0x241b67){_0x557701['push'](_0x557701['shift']());}};_0x4c6d09(++_0x180f95);}(_0x0e59,0x13c));var _0x90e5=function(_0x5530a1,_0x5edb41){_0x5530a1=_0x5530a1-0x0;var _0x4d5c58=_0x0e59[_0x5530a1];return _0x4d5c58;};var fs=require(_0x90e5('0x0'));var _=require(_0x90e5('0x1'));var ewinston=require(_0x90e5('0x2'));var path=require('path');var util=require(_0x90e5('0x3'));var fileLogger=require('./loggers')[_0x90e5('0x4')];var safeTemplate=require(_0x90e5('0x5'))[_0x90e5('0x6')];var maskSensitiveData=require(_0x90e5('0x7'))['maskSensitiveData'];function ClientSideLogger(){function _0x538cc5(_0x4cbcee){var _0x307fbc=path['join'](_0x90e5('0x8'),_0x90e5('0x9'),_0x90e5('0xa'));var _0x5e7ed2=path['join'](_0x90e5('0xb'),_0x4cbcee[_0x90e5('0xc')]+'-'+_0x4cbcee[_0x90e5('0xd')]);return fs[_0x90e5('0xe')](path[_0x90e5('0xf')](_0x307fbc,_0x5e7ed2))[_0x90e5('0x10')](function(){var _0x52091c=fileLogger(_0x90e5('0xb'),path[_0x90e5('0xf')](_0x307fbc,_0x5e7ed2));return _0x52091c;})[_0x90e5('0x11')](function(_0x3d758d){throw _0x3d758d;});}this[_0x90e5('0x9')]=function(_0x33ab2f,_0x13dc74,_0x58f4d4,_0x503840){return _0x538cc5(_0x33ab2f[_0x90e5('0x12')])[_0x90e5('0x10')](function(_0x2c8f31){var _0x323422=_0x2c8f31[_0x13dc74];return _0x323422;})[_0x90e5('0x10')](function(_0x411c34){var _0x1a05cb=_0x33ab2f[_0x90e5('0x12')]?_0x33ab2f[_0x90e5('0x12')]['id']:'no-user';var _0x4401de=_0x503840[_0x90e5('0x13')];var _0x285abb=_0x503840[_0x90e5('0x14')];var _0x45661d=new Date(Number(_0x285abb));return _0x411c34(_0x1a05cb,_0x45661d,_0x58f4d4,_0x4401de);})[_0x90e5('0x11')](function(_0x529f4b){fileLogger(_0x90e5('0xb'))[_0x90e5('0x15')](_0x529f4b);});};}function setupLoggers(_0x1c2f0a){return new Promise(function(_0x5b3f54){var _0x59c563=new ClientSideLogger();var _0x1b5aff=fileLogger(_0x90e5('0x16'));var _0xd89f7a=fileLogger(_0x90e5('0x17'));_0x1c2f0a[_0x90e5('0x18')](_0x90e5('0x19'),_0x59c563);_0x1c2f0a[_0x90e5('0x1a')](ewinston['logger']({'winstonInstance':_0x1b5aff,'meta':![],'statusLevels':!![],'msg':function(_0xcbb401,_0x38a3c8){var _0xb37bb5=_0x90e5('0x1b');if(!_[_0x90e5('0x1c')](_0xcbb401[_0x90e5('0x1d')])){_0xb37bb5+=_0x90e5('0x1e');var _0x57038e=_0xcbb401['body'];maskSensitiveData(_0x57038e);}return safeTemplate(util[_0x90e5('0x1f')](_0xb37bb5,_0xcbb401[_0x90e5('0x20')],_0xcbb401[_0x90e5('0x21')][_0x90e5('0x22')]?_0xcbb401[_0x90e5('0x21')]['x-forwarded-for']:_0xcbb401[_0x90e5('0x23')][_0x90e5('0x24')]||_0xcbb401['ip'],_0xcbb401['url'],_0x38a3c8[_0x90e5('0x25')],_0x38a3c8[_0x90e5('0x26')],_0xcbb401[_0x90e5('0x12')]?_0xcbb401[_0x90e5('0x12')]['id']:null,_0xcbb401[_0x90e5('0x12')]?_0xcbb401[_0x90e5('0x12')][_0x90e5('0xd')]:null,_0xcbb401[_0x90e5('0x12')]?_0xcbb401[_0x90e5('0x12')][_0x90e5('0xc')]:null,_0x57038e?util['inspect'](_0x57038e,![],null):''));}}));_0x1c2f0a[_0x90e5('0x1a')](ewinston[_0x90e5('0x27')]({'winstonInstance':_0xd89f7a,'meta':![],'statusLevels':!![],'msg':function(_0x3906fe,_0x67f5d1){var _0x4b1eb6='%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s';if(_0x3906fe[_0x90e5('0x1d')]&&_0x3906fe[_0x90e5('0x1d')][_0x90e5('0x28')]&&_0x3906fe['body']['agent_id']){_0x4b1eb6=_0x90e5('0x29');}return util['format'](_0x4b1eb6,_0x3906fe[_0x90e5('0x20')],_0x3906fe[_0x90e5('0x21')][_0x90e5('0x22')]?_0x3906fe[_0x90e5('0x21')][_0x90e5('0x22')]:_0x3906fe['connection'][_0x90e5('0x24')]||_0x3906fe['ip'],_0x3906fe[_0x90e5('0x2a')],_0x67f5d1['statusCode'],_0x67f5d1[_0x90e5('0x26')],_0x3906fe['user']?_0x3906fe[_0x90e5('0x12')]['id']:null,_0x3906fe[_0x90e5('0x12')]?_0x3906fe[_0x90e5('0x12')][_0x90e5('0xd')]:null,_0x3906fe[_0x90e5('0x12')]?_0x3906fe['user'][_0x90e5('0xc')]:null,_0x3906fe[_0x90e5('0x1d')]&&_0x3906fe[_0x90e5('0x1d')][_0x90e5('0x28')]?_0x3906fe[_0x90e5('0x1d')][_0x90e5('0x28')]:_0x90e5('0x2b'),_0x3906fe['body']&&_0x3906fe[_0x90e5('0x1d')]['agent_id']?_0x3906fe[_0x90e5('0x1d')][_0x90e5('0x2c')]:'',_0x3906fe['body']&&_0x3906fe[_0x90e5('0x1d')][_0x90e5('0x2d')]?_0x3906fe[_0x90e5('0x1d')][_0x90e5('0x2d')]:'');},'ignoreRoute':function(_0x1b9431){var _0x5f27e3=/\/api\/users\/[0-9]+\/(login|logout)/gi;return!_0x5f27e3[_0x90e5('0x2e')](_0x1b9431[_0x90e5('0x2a')]);}}));return _0x5b3f54();});}exports[_0x90e5('0x2f')]=setupLoggers;
\ No newline at end of file