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-30 20:33:31 +00:00
|
|
|
final class Log {
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-02-08 21:11:39 +00:00
|
|
|
/**
|
|
|
|
* @return boolean Returns true when successful.
|
|
|
|
*/
|
2016-01-31 17:49:31 +00:00
|
|
|
public static function notice($connection, $function, $line, $text = '') {
|
2014-05-06 20:11:37 +00:00
|
|
|
|
2016-01-31 17:49:31 +00:00
|
|
|
return Log::text($connection, 'notice', $function, $line, $text);
|
2014-05-06 20:11:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-08 21:11:39 +00:00
|
|
|
/**
|
|
|
|
* @return boolean Returns true when successful.
|
|
|
|
*/
|
2016-01-31 17:49:31 +00:00
|
|
|
public static function error($connection, $function, $line, $text = '') {
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-01-31 17:49:31 +00:00
|
|
|
return Log::text($connection, 'error', $function, $line, $text);
|
2014-05-06 20:11:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-08 21:11:39 +00:00
|
|
|
/**
|
|
|
|
* @return boolean Returns true when successful.
|
|
|
|
*/
|
2016-01-31 17:49:31 +00:00
|
|
|
private static function text($connection, $type, $function, $line, $text = '') {
|
2014-05-06 20:11:37 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Check dependencies
|
2016-01-31 17:49:31 +00:00
|
|
|
Validator::required(isset($connection, $type, $function, $line, $text), __METHOD__);
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Get time
|
2014-05-06 19:22:56 +00:00
|
|
|
$sysstamp = time();
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Save in database
|
2016-01-31 17:49:31 +00:00
|
|
|
$query = Database::prepare($connection, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
|
|
|
|
$result = Database::execute($connection, $query, null, null);
|
2014-05-06 19:22:56 +00:00
|
|
|
|
2016-01-31 14:44:54 +00:00
|
|
|
if ($result===false) return false;
|
2014-05-06 20:11:37 +00:00
|
|
|
return true;
|
2014-05-06 19:22:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|