1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Fix Aphlict logging

Summary:
Yeahhhhhhhh....

  - Open a "stream", not a "steam".
  - Make error easier for users to understand.
  - Write to the log in debug mode so the issue is more apparent.

Test Plan:
  - Started server with bad permissions, got usable error message.
  - Started server with good permissions, got logfile.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11339
This commit is contained in:
epriestley 2015-01-12 08:16:08 -08:00
parent 790d250967
commit 0d070c91dc
3 changed files with 23 additions and 7 deletions

View file

@ -136,9 +136,7 @@ abstract class PhabricatorAphlictManagementWorkflow
$server_argv[] = '--ssl-cert='.$ssl_cert; $server_argv[] = '--ssl-cert='.$ssl_cert;
} }
if (!$this->debug) { $server_argv[] = '--log='.$log;
$server_argv[] = '--log='.$log;
}
if ($this->clientHost) { if ($this->clientHost) {
$server_argv[] = '--client-host='.$this->clientHost; $server_argv[] = '--client-host='.$this->clientHost;

View file

@ -43,7 +43,25 @@ var debug = new JX.AphlictLog()
var config = parse_command_line_arguments(process.argv); var config = parse_command_line_arguments(process.argv);
process.on('uncaughtException', function(err) { process.on('uncaughtException', function(err) {
debug.log('\n<<< UNCAUGHT EXCEPTION! >>>\n' + err.stack); var context = null;
if ((err.code == 'EACCES') &&
(err.path == config.log)) {
context = util.format(
'Unable to open logfile ("%s"). Check that permissions are set ' +
'correctly.',
err.path);
}
var message = [
'\n<<< UNCAUGHT EXCEPTION! >>>',
];
if (context) {
message.push(context);
}
message.push(err.stack);
debug.log(message.join('\n\n'));
process.exit(1); process.exit(1);
}); });
@ -69,8 +87,8 @@ if (ssl_config.enabled) {
} }
// Add the logfile so we'll fail if we can't write to it. // Add the logfile so we'll fail if we can't write to it.
if (config.logfile) { if (config.log) {
debug.addLogfile(config.logfile); debug.addLogfile(config.log);
} }
// If we're just doing a configuration test, exit here before starting any // If we're just doing a configuration test, exit here before starting any

View file

@ -20,7 +20,7 @@ JX.install('AphlictLog', {
mode: 066 mode: 066
}; };
var logfile = fs.createWriteSteam(path, options); var logfile = fs.createWriteStream(path, options);
this._writeToLogs.push(logfile); this._writeToLogs.push(logfile);