Log.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. ###
  3. # @name Log Module
  4. # @copyright 2015 by Tobias Reich
  5. ###
  6. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  7. final class Log extends Module {
  8. public static function notice($database, $function, $line, $text = '') {
  9. return Log::text($database, 'notice', $function, $line, $text);
  10. }
  11. public static function warning($database, $function, $line, $text = '') {
  12. return Log::text($database, 'warning', $function, $line, $text);
  13. }
  14. public static function error($database, $function, $line, $text = '') {
  15. return Log::text($database, 'error', $function, $line, $text);
  16. }
  17. public static function text($database, $type, $function, $line, $text = '') {
  18. # Check dependencies
  19. Module::dependencies(isset($database, $type, $function, $line, $text));
  20. # Get time
  21. $sysstamp = time();
  22. # Save in database
  23. $query = Database::prepare($database, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
  24. $result = $database->query($query);
  25. if (!$result) return false;
  26. return true;
  27. }
  28. }
  29. ?>