Ahora se capturan y envian todos los mensajes de error y advertencia al syslog

This commit is contained in:
Juan Ferrer Toribio 2015-08-28 02:44:34 +02:00
parent 929eb0972b
commit 39e436e275
10 changed files with 106 additions and 35 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.207-1) stable; urgency=low
hedera-web (1.208-1) stable; urgency=low
* Initial Release.

View File

@ -10,4 +10,8 @@ if (!defined (__NAMESPACE__.'\_DEVELOPER_MODE'))
require_once (_CONFIG_DIR .'/config.php');
ini_set ('log_errors', TRUE);
ini_set ('error_log', 'syslog');
//ini_set ('error_log', _LOG_DIR .'/hedera-web.log');
?>

View File

@ -19,9 +19,8 @@ class Tpv
{
global $conf;
ini_set ('log_errors', TRUE);
ini_set ('error_log', Hedera\_LOG_DIR .'/hedera-web.log');
openlog ('hedera-web', LOG_ODELAY, LOG_LOCAL0);
self::$conn = new Db\Conn ();
self::$conn->open (
$conf['db']['host']
@ -37,6 +36,7 @@ class Tpv
static function deinit ()
{
self::$conn->close ();
closelog ();
}
/**

View File

@ -1,5 +1,7 @@
<?php
openlog ('hedera-web', LOG_ODELAY, LOG_LOCAL0);
require_once ('vn/hedera/web.php');
require_once ('vn/hedera/js.php');
require_once ('vn/hedera/util.php');
@ -7,12 +9,10 @@ require_once ('vn/hedera/util.php');
use Vn\Hedera\Web;
use Vn\Lib\Locale;
ini_set ('log_errors', TRUE);
ini_set ('error_log', Vn\Hedera\_LOG_DIR .'/hedera-web.log');
function myExitHandler ()
{
Web::deinit ();
closelog ();
}
function myGlobalErrorHandler ()
@ -24,7 +24,7 @@ function myGlobalErrorHandler ()
function myErrorHandler ($errno, $message, $file, $line, $context)
{
error_log ("$file:$line: $message");
error_log ("Error: $file($line): $message");
switch ($errno)
{
@ -37,7 +37,12 @@ function myErrorHandler ($errno, $message, $file, $line, $context)
function myExceptionHandler ($e)
{
error_log ($e->getFile () .':'. $e->getLine () .': '. $e->getMessage ());
error_log (sprintf ('Exception: %s(%d): %s. Trace: %s'
,$e->getFile ()
,$e->getLine ()
,$e->getMessage ()
,$e->getTraceAsString ()
));
myGlobalErrorHandler ();
}

View File

@ -180,6 +180,7 @@ Db.Conn.implement
*/
,execDone: function (httpRequest, callback, success)
{
var e;
var error = null;
var results = null;
@ -189,7 +190,10 @@ Db.Conn.implement
this.signalEmit ('loading-changed', false);
if (!success)
error = new Vn.Error ('Http', 'connError', _('ConnError'));
{
error = new Vn.Error ('Conn', 'connError', _('ConnError'));
this.signalEmit ('error', error);
}
else
try {
var json = httpRequest.getJson ();
@ -231,17 +235,20 @@ Db.Conn.implement
}
}
}
catch (e) {
error = new Vn.Error ('Http', 'badReply', e.message);
catch (e)
{
this.signalEmit ('error', e);
error = e;
}
var errorHandled = false;
if (callback)
errorHandled = callback (new Db.ResultSet (results, error));
if (error && errorHandled != true)
this.signalEmit ('error', error);
try {
callback (new Db.ResultSet (results, error));
}
catch (e)
{
this.signalEmit ('error', e);
}
}
});

View File

@ -19,7 +19,7 @@ Vn.HttpRequest = new Class
,requestStateChanged: function (callback)
{
if (this.request.readyState == 4)
if (this.request.readyState == 4 && callback)
callback (this, this.request.status == 200);
}

20
web/log.php Executable file
View File

@ -0,0 +1,20 @@
<?php
openlog ('hedera-web', LOG_ODELAY, LOG_LOCAL0);
require_once ('vn/hedera/init.php');
if (isset ($_REQUEST['file'])
&& isset ($_REQUEST['line'])
&& isset ($_REQUEST['message'])
&& isset ($_REQUEST['stack']))
error_log (sprintf ('Javascript: %s(%d): %s. Stack: %s'
,$_REQUEST['file']
,$_REQUEST['line']
,$_REQUEST['message']
,$_REQUEST['stack']
));
closeLog ();
?>

View File

@ -5,22 +5,22 @@
img
{
position: absolute;
margin-top: -18em;
margin-left: -18em;
margin-top: -200px;
margin-left: -200px;
top: 50%;
left: 50%;
}
#continue
{
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
margin: 15px;
bottom: 0;
left: 0;
right: 0;
margin: 1em;
text-align: center;
}
a
{
color: #444;
border-width: 0px;
border-width: 0;
}

View File

@ -14,6 +14,11 @@ Vn.Web =
,initialize: function ()
{
window.onerror = function (error, a, b, c, d)
{
this.errorHandler.bind (this, error);
}.bind (this);
this.loadingCount = 0;
this.loader = $('loader');
this.formHolder = $('form-holder');
@ -157,8 +162,9 @@ Vn.Web =
this.onFormChange ();
}
,onConnError: function (conn, error)
,errorHandler: function (error)
{
if (error instanceof Vn.Error)
switch (error.domain)
{
case 'Auth':
@ -172,9 +178,29 @@ Vn.Web =
Htk.Toast.showError (error.message);
break;
default:
console.warn (error.message);
console.error (error.message);
Htk.Toast.showError (_('InternalError'));
}
else
{
console.error (error);
Htk.Toast.showError (_('InternalError'));
var httpRequest = new Vn.HttpRequest ()
httpRequest.add
({
'file': error.fileName
,'line': error.lineNumber
,'message': error.message
,'stack': error.stack
});
httpRequest.send ('log.php');
}
}
,onConnError: function (conn, error)
{
this.errorHandler (error);
}
,onConnLoading: function (conn, isLoading)
@ -206,8 +232,10 @@ Vn.Web =
,newVersion: function (error)
{
if (this.skipVersion)
if (this.newVersionBlock || this.skipVersion)
return;
this.newVersionBlock = true;
var reload;
var message = _('NewVersionAvailable') +"\n\n"+ error.message;
@ -228,6 +256,8 @@ Vn.Web =
this.unload ();
location.reload ();
}
this.newVersionBlock = false;
}
,createMenu: function (res, sectionMap, parent, ul)
@ -426,7 +456,7 @@ Vn.Web =
}
catch (e) {
formInfo.error = true;
console.error (e);
this.errorHandler (error);
}
}
else

View File

@ -1,5 +1,7 @@
<?php
openlog ('hedera-web', LOG_ODELAY, LOG_LOCAL0);
require_once ('vn/hedera/web.php');
require_once ('vn/rest/rest.php');
@ -7,13 +9,11 @@ use Vn\Lib\Locale;
use Vn\Rest;
use Vn\Hedera\Web;
ini_set ('log_errors', TRUE);
ini_set ('error_log', Vn\Hedera\_LOG_DIR .'/hedera-web.log');
function myExitHandler ()
{
Web::deinit ();
Rest\Service::sendReply ();
closelog ();
}
function myGlobalErrorHandler ()
@ -25,7 +25,7 @@ function myGlobalErrorHandler ()
function myErrorHandler ($errno, $message, $file, $line, $context)
{
error_log ("$file:$line: $message");
error_log ("Error: $file($line): $message");
switch ($errno)
{
@ -40,7 +40,12 @@ function myErrorHandler ($errno, $message, $file, $line, $context)
function myExceptionHandler ($e)
{
error_log ($e->getFile () .':'. $e->getLine () .': '. $e->getMessage ());
error_log (sprintf ('Exception: %s(%d): %s. Trace: %s'
,$e->getFile ()
,$e->getLine ()
,$e->getMessage ()
,$e->getTraceAsString ()
));
myGlobalErrorHandler ();
}