mardi 1 décembre 2015

PHP: use one global file pointer in a static `log` method

I'd like to call a log method statically throughout my app:

App::log('Some message');

but then I'd like to create a file pointer only once, so that it's accessible from within that method($file_pointer) each time it's called.

public static function log($message) {
  (...)
  fwrite($file_pointer, $processed_message);
}

Is there a design pattern or any other architectural solution that addresses this problem?

Aucun commentaire:

Enregistrer un commentaire