logging - PHP: Log into an "global array" -


i've got question.

i'm running little php-cli-script calls functions helper-class.

like this:

test.php

$testhelper         =           new testhelper();     $test = $testhelper->method1(); if($test) $testhelper->method2(); 

helper.php

class testhelper { public static function method1() { ... addlogfunction("this test-log-entry"); } public static function method2() { ... addlogfunction("this test-log-entry"); } ... } 

both methods defined in helper.php.

now write information, generated running both methods, "global log". log should contain information both called methods.

in case "global log" should contain "this test-log-entry" , "this test-log-entry" after running both methods successively.

how solve that?

add log messages array, , hope there way output later. because if script crashes, array lost, , log won't useful debugging.

command line scripts write stderr errors, usable other command line tools, can written log files etc.

error_log() if configured correctly (the error_log configuration directive).

you directly write stderr:

fwrite(stderr, "log messages error channel\n"); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -