@ -14,11 +14,26 @@ abstract class File
public $filename ;
public $logger ;
private $logger ;
private $error_stream ;
public function __construct ()
{
$this -> logger = Logger :: getInstance ();
}
public function log ( $message )
{
if ( Config :: get ( 'LOGGING' )) {
if ( is_null ( $this -> logger )) {
$this -> logger = Logger :: getInstance ();
}
$this -> logger -> log ( $message );
} else {
$this -> error_stream = Config :: get ( 'ErrorStream' , 'php://stderr' );
file_put_contents ( $this -> error_stream , PHP_EOL . 'Log ' . '#' . __CLASS__ . ': ' . $message . PHP_EOL , FILE_APPEND );
}
}
/**
@ -33,7 +48,7 @@ abstract class File
if ( ! is_array ( $data )) {
$data = json_decode ( $data , true );
if ( json_last_error () != JSON_ERROR_NONE ) {
$instance -> logger -> log ( 'Unable to convert json-string to array. Data ' . print_r ( $data , true ));
$instance -> log ( 'Unable to convert json-string to array. Data ' . print_r ( $data , true ));
}
}
if ( is_array ( $data )) {
@ -65,6 +80,7 @@ abstract class File
/**
* @ return string
* TODO : Сделать настройку для изображения - заглушки применительно к Image
*/
public function getWebName ()
{