Write errors to stderr
[phinde.git] / src / phinde / Log.php
1 <?php
2 namespace phinde;
3
4 class Log
5 {
6     public static function error($msg)
7     {
8         static::log($msg, STDERR);
9     }
10
11     public static function info($msg)
12     {
13         if ($GLOBALS['phinde']['debug']) {
14             static::log($msg);
15         }
16     }
17
18     public static function log($msg, $stream = STDOUT)
19     {
20         if (isset($GLOBALS['phinde']['logfile'])
21             && $GLOBALS['phinde']['logfile'] != ''
22         ) {
23             file_put_contents(
24                 $GLOBALS['phinde']['logfile'],
25                 $msg . "\n", FILE_APPEND
26             );
27         } else {
28             fwrite($stream, $msg . "\n");
29         }
30     }
31 }
32 ?>