2014-05-06 19:22:56 +00:00
|
|
|
<?php
|
|
|
|
|
2016-01-26 14:31:53 +00:00
|
|
|
namespace Lychee\Modules;
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-01-19 10:45:41 +00:00
|
|
|
final class Log extends Module {
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
public static function notice($function, $line, $text = '') {
|
2014-05-06 20:11:37 +00:00
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
return Log::text('notice', $function, $line, $text);
|
2014-05-06 20:11:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
public static function warning($function, $line, $text = '') {
|
2014-05-06 20:11:37 +00:00
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
return Log::text('warning', $function, $line, $text);
|
2014-05-06 20:11:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
public static function error($function, $line, $text = '') {
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
return Log::text('error', $function, $line, $text);
|
2014-05-06 20:11:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
private static function text($type, $function, $line, $text = '') {
|
2014-05-06 20:11:37 +00:00
|
|
|
|
2014-05-06 19:22:56 +00:00
|
|
|
# Check dependencies
|
2016-01-24 21:14:20 +00:00
|
|
|
Module::dependencies(isset($type, $function, $line, $text));
|
2014-05-06 19:22:56 +00:00
|
|
|
|
|
|
|
# Get time
|
|
|
|
$sysstamp = time();
|
|
|
|
|
|
|
|
# Save in database
|
2016-01-24 21:14:20 +00:00
|
|
|
$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;
|
2014-05-06 20:11:37 +00:00
|
|
|
return true;
|
2014-05-06 19:22:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|