lychee/php/modules/Log.php

49 lines
1.0 KiB
PHP
Raw Normal View History

2014-05-06 19:22:56 +00:00
<?php
###
# @name Log Module
2015-02-01 21:08:37 +00:00
# @copyright 2015 by Tobias Reich
2014-05-06 19:22:56 +00:00
###
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
final class Log extends Module {
2014-05-06 19:22:56 +00:00
public static function notice($function, $line, $text = '') {
return Log::text('notice', $function, $line, $text);
}
public static function warning($function, $line, $text = '') {
return Log::text('warning', $function, $line, $text);
}
public static function error($function, $line, $text = '') {
2014-05-06 19:22:56 +00:00
return Log::text('error', $function, $line, $text);
}
private static function text($type, $function, $line, $text = '') {
2014-05-06 19:22:56 +00:00
# Check dependencies
Module::dependencies(isset($type, $function, $line, $text));
2014-05-06 19:22:56 +00:00
# Get time
$sysstamp = time();
# Save in database
$query = Database::prepare(Database::get(), "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
$result = Database::get()->query($query);
2014-05-06 19:22:56 +00:00
if (!$result) return false;
return true;
2014-05-06 19:22:56 +00:00
}
}
?>