Log.php 1.1 KB

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