aboutsummaryrefslogtreecommitdiff
path: root/src/phinde/Log.php
blob: 36a126b5f5f71a36a88cb98ec5f17472eb5e143b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace phinde;

class Log
{
    public static function error($msg)
    {
        static::log($msg, STDERR);
    }

    public static function info($msg)
    {
        if ($GLOBALS['phinde']['debug']) {
            static::log($msg);
        }
    }

    public static function log($msg, $stream = STDOUT)
    {
        if (isset($GLOBALS['phinde']['logfile'])
            && $GLOBALS['phinde']['logfile'] != ''
        ) {
            file_put_contents(
                $GLOBALS['phinde']['logfile'],
                $msg . "\n", FILE_APPEND
            );
        } else {
            fwrite($stream, $msg . "\n");
        }
    }
}
?>