Log.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Lychee\Modules;
  3. final class Log {
  4. public static function notice($connection, $function, $line, $text = '') {
  5. return Log::text($connection, 'notice', $function, $line, $text);
  6. }
  7. public static function warning($connection, $function, $line, $text = '') {
  8. return Log::text($connection, 'warning', $function, $line, $text);
  9. }
  10. public static function error($connection, $function, $line, $text = '') {
  11. return Log::text($connection, 'error', $function, $line, $text);
  12. }
  13. private static function text($connection, $type, $function, $line, $text = '') {
  14. // Check dependencies
  15. Validator::required(isset($connection, $type, $function, $line, $text), __METHOD__);
  16. // Get time
  17. $sysstamp = time();
  18. // Save in database
  19. $query = Database::prepare($connection, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
  20. $result = Database::execute($connection, $query, null, null);
  21. if ($result===false) return false;
  22. return true;
  23. }
  24. }
  25. ?>