@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reduce the verbosity of the "Aphlict" log

Summary:
See PHI1692. Currently, the Aphlict log is ridiculously verbose. As an initial pass at improving this:

- When starting in "debug" mode, pass "--debug=1" to Node.
- In Node, separate logging into "log" (lower-volume, more-important messages) and "trace" (higher-volume, less-important messages).
- Only print "trace" messages in "debug" mode.

Test Plan: Ran Aphlict in debug and non-debug modes. Behavior unchanged in debug mode, but log has more sensible verbosity in non-debug mode.

Differential Revision: https://secure.phabricator.com/D21115

+70 -17
+8 -1
src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
··· 550 550 } 551 551 552 552 private function getStartCommand(array $server_argv) { 553 + $launch_argv = array(); 554 + 555 + if ($this->debug) { 556 + $launch_argv[] = '--debug=1'; 557 + } 558 + 553 559 return csprintf( 554 - '%R %Ls -- %s %Ls', 560 + '%R %Ls -- %s %Ls %Ls', 555 561 $this->getNodeBinary(), 556 562 $this->getNodeArgv(), 557 563 $this->getAphlictScriptPath(), 564 + $launch_argv, 558 565 $server_argv); 559 566 } 560 567
+7 -2
support/aphlict/server/aphlict_server.js
··· 9 9 function parse_command_line_arguments(argv) { 10 10 var args = { 11 11 test: false, 12 + debug: false, 12 13 config: null 13 14 }; 14 15 ··· 34 35 35 36 require('./lib/AphlictLog'); 36 37 37 - var debug = new JX.AphlictLog() 38 - .addConsole(console); 38 + var debug = new JX.AphlictLog(); 39 39 40 40 var args = parse_command_line_arguments(process.argv); 41 41 var config = parse_config(args); 42 + 43 + if (args.test || args.debug) { 44 + debug.addConsole(console); 45 + debug.setTrace(true); 46 + } 42 47 43 48 function set_exit_code(code) { 44 49 process.on('exit', function() {
+14 -4
support/aphlict/server/lib/AphlictAdminServer.js
··· 4 4 5 5 require('./AphlictListenerList'); 6 6 7 - var http = require('http'); 8 7 var url = require('url'); 9 8 10 9 JX.install('AphlictAdminServer', { ··· 54 53 return this; 55 54 }, 56 55 56 + trace: function() { 57 + var logger = this.getLogger(); 58 + if (!logger) { 59 + return; 60 + } 61 + 62 + logger.trace.apply(logger, arguments); 63 + 64 + return this; 65 + }, 66 + 57 67 listen: function() { 58 68 return this._server.listen.apply(this._server, arguments); 59 69 }, ··· 76 86 try { 77 87 var msg = JSON.parse(body); 78 88 79 - self.log( 89 + self.trace( 80 90 'Received notification (' + instance + '): ' + 81 91 JSON.stringify(msg)); 82 92 ++self._messagesIn; ··· 201 211 listener.writeMessage(message); 202 212 203 213 ++this._messagesOut; 204 - this.log( 214 + this.trace( 205 215 '<%s> Wrote Message', 206 216 listener.getDescription()); 207 217 } catch (error) { 208 218 list.removeListener(listener); 209 219 210 - this.log( 220 + this.trace( 211 221 '<%s> Write Error: %s', 212 222 listener.getDescription(), 213 223 error);
+27 -10
support/aphlict/server/lib/AphlictClientServer.js
··· 3 3 var JX = require('./javelin').JX; 4 4 5 5 require('./AphlictListenerList'); 6 - require('./AphlictLog'); 7 6 8 7 var url = require('url'); 9 8 var util = require('util'); ··· 60 59 return this; 61 60 }, 62 61 62 + trace: function() { 63 + var logger = this.getLogger(); 64 + if (!logger) { 65 + return; 66 + } 67 + 68 + logger.trace.apply(logger, arguments); 69 + 70 + return this; 71 + }, 72 + 63 73 _onrequest: function(request, response) { 64 74 // The websocket code upgrades connections before they get here, so 65 75 // this only handles normal HTTP connections. We just fail them with ··· 104 114 105 115 var listener = self.getListenerList(instance).addListener(ws); 106 116 117 + function msg(argv) { 118 + return util.format('<%s>', listener.getDescription()) + 119 + ' ' + 120 + util.format.apply(null, argv); 121 + } 122 + 107 123 function log() { 108 - self.log( 109 - util.format('<%s>', listener.getDescription()) + 110 - ' ' + 111 - util.format.apply(null, arguments)); 124 + self.log(msg(arguments)); 112 125 } 113 126 114 - log('Connected from %s.', ws._socket.remoteAddress); 127 + function trace() { 128 + self.trace(msg(arguments)); 129 + } 130 + 131 + trace('Connected from %s.', ws._socket.remoteAddress); 115 132 116 133 ws.on('message', function(data) { 117 - log('Received message: %s', data); 134 + trace('Received message: %s', data); 118 135 119 136 var message; 120 137 try { ··· 126 143 127 144 switch (message.command) { 128 145 case 'subscribe': 129 - log( 146 + trace( 130 147 'Subscribed to: %s', 131 148 JSON.stringify(message.data)); 132 149 listener.subscribe(message.data); 133 150 break; 134 151 135 152 case 'unsubscribe': 136 - log( 153 + trace( 137 154 'Unsubscribed from: %s', 138 155 JSON.stringify(message.data)); 139 156 listener.unsubscribe(message.data); ··· 180 197 181 198 ws.on('close', function() { 182 199 self.getListenerList(instance).removeListener(listener); 183 - log('Disconnected.'); 200 + trace('Disconnected.'); 184 201 }); 185 202 }); 186 203
+14
support/aphlict/server/lib/AphlictLog.js
··· 14 14 members: { 15 15 _consoles: null, 16 16 _logs: null, 17 + _trace: null, 18 + 19 + setTrace: function(trace) { 20 + this._trace = trace; 21 + return this; 22 + }, 17 23 18 24 addConsole: function(console) { 19 25 this._consoles.push(console); ··· 27 33 mode: '0664', 28 34 })); 29 35 return this; 36 + }, 37 + 38 + trace: function() { 39 + if (!this._trace) { 40 + return; 41 + } 42 + 43 + return this.log.apply(this, arguments); 30 44 }, 31 45 32 46 log: function() {