Error report meldungscript

  • Error report meldungscript

    Hallo Ihr lieben

    Hab da mal so eine frage, Undzwar wie macht man sich so ein error report script . oder gibts es dafür schon Howtos oder fertige scripte? Wüsste nicht wie man sowas in die dat umsetzt


    So sah das ungefähr aus wo ich es gesehn habe

    You can report this error by clicking the link: Report Error
    The report contains: Error Level, Error Message, File where Error occured, Line where Error occured, TWA Version
    The application was halted.


    Als ich auf den link Report Error geklickt hatte, hatte ich einen weisse seite wo nur dies drine stand

    Thank You, your report was added to our database. / Vielen Dank, ihr Report wurde unserer Datenbank hinzugefügt.

    Habt ihr da ein paar ideen oder vorschläge für mich?
    Würde mich seh freuen.

    Gruss

    Dragon
  • du machst einfach um deinen ganzen Code ein try/catch.

    Und im Fehlerfall übermittelst du einfach welche Aktion gerade ausgeführt wurde und ein paar für dich wichtige Variablen. IP Adresse sollte das wichtigste sein, damit du seinen Weg in den Logfiles nachvollziehen kannst.

    Quellcode

    1. <?php
    2. try {
    3. //dein ganzer Code
    4. } catch (Exception $e) {
    5. $spacer = "\n------------------------------\n";
    6. $report = $e->getMessage().$spacer.
    7. date("d.m.Y H:i:s").$spacer.
    8. __FILE__ . "#" . __LINE__.$spacer.
    9. print_r($_SERVER, true).$spacer.
    10. print_r($_POST, true).$spacer.
    11. print_r($_GET, true).$spacer.
    12. print_r($_SESSION, true);
    13. echo "Senden?";
    14. }
    15. ?>
    Alles anzeigen
  • achso. Dann hast du wohl kein PHP 5
    Dann lies dir dieses Kapitel durch. Mit [phpdoc]trigger_error[/phpdoc] kommst du auch zum Erfolg.

    Quellcode

    1. <?php
    2. // we will do our own error handling
    3. error_reporting(0);
    4. // user defined error handling function
    5. function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
    6. {
    7. // timestamp for the error entry
    8. $dt = date("Y-m-d H:i:s (T)");
    9. // define an assoc array of error string
    10. // in reality the only entries we should
    11. // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    12. // E_USER_WARNING and E_USER_NOTICE
    13. $errortype = array (
    14. E_ERROR => 'Error',
    15. E_WARNING => 'Warning',
    16. E_PARSE => 'Parsing Error',
    17. E_NOTICE => 'Notice',
    18. E_CORE_ERROR => 'Core Error',
    19. E_CORE_WARNING => 'Core Warning',
    20. E_COMPILE_ERROR => 'Compile Error',
    21. E_COMPILE_WARNING => 'Compile Warning',
    22. E_USER_ERROR => 'User Error',
    23. E_USER_WARNING => 'User Warning',
    24. E_USER_NOTICE => 'User Notice',
    25. E_STRICT => 'Runtime Notice',
    26. E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
    27. );
    28. // set of errors for which a var trace will be saved
    29. $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    30. $err = "<errorentry>\n";
    31. $err .= "\t<datetime>" . $dt . "</datetime>\n";
    32. $err .= "\t<errornum>" . $errno . "</errornum>\n";
    33. $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n";
    34. $err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
    35. $err .= "\t<scriptname>" . $filename . "</scriptname>\n";
    36. $err .= "\t<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
    37. if (in_array($errno, $user_errors)) {
    38. $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
    39. }
    40. $err .= "</errorentry>\n\n";
    41. // for testing
    42. // echo $err;
    43. // save to the error log, and e-mail me if there is a critical user error
    44. error_log($err, 3, "/usr/local/php4/error.log");
    45. if ($errno == E_USER_ERROR) {
    46. mail("phpdev@example.com", "Critical User Error", $err);
    47. }
    48. }
    49. function distance($vect1, $vect2)
    50. {
    51. if (!is_array($vect1) || !is_array($vect2)) {
    52. trigger_error("Incorrect parameters, arrays expected", E_USER_ERROR);
    53. return NULL;
    54. }
    55. if (count($vect1) != count($vect2)) {
    56. trigger_error("Vectors need to be of the same size", E_USER_ERROR);
    57. return NULL;
    58. }
    59. for ($i=0; $i<count($vect1); $i++) {
    60. $c1 = $vect1[$i]; $c2 = $vect2[$i];
    61. $d = 0.0;
    62. if (!is_numeric($c1)) {
    63. trigger_error("Coordinate $i in vector 1 is not a number, using zero",
    64. E_USER_WARNING);
    65. $c1 = 0.0;
    66. }
    67. if (!is_numeric($c2)) {
    68. trigger_error("Coordinate $i in vector 2 is not a number, using zero",
    69. E_USER_WARNING);
    70. $c2 = 0.0;
    71. }
    72. $d += $c2*$c2 - $c1*$c1;
    73. }
    74. return sqrt($d);
    75. }
    76. $old_error_handler = set_error_handler("userErrorHandler");
    77. // undefined constant, generates a warning
    78. $t = I_AM_NOT_DEFINED;
    79. // define some "vectors"
    80. $a = array(2, 3, "foo");
    81. $b = array(5.5, 4.3, -1.6);
    82. $c = array(1, -3);
    83. // generate a user error
    84. $t1 = distance($c, $b) . "\n";
    85. // generate another user error
    86. $t2 = distance($b, "i am not an array") . "\n";
    87. // generate a warning
    88. $t3 = distance($a, $b) . "\n";
    89. ?>
    Alles anzeigen