Log.php 929 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 error($connection, $function, $line, $text = '') {
  8. return Log::text($connection, 'error', $function, $line, $text);
  9. }
  10. private static function text($connection, $type, $function, $line, $text = '') {
  11. // Check dependencies
  12. Validator::required(isset($connection, $type, $function, $line, $text), __METHOD__);
  13. // Get time
  14. $sysstamp = time();
  15. // Save in database
  16. $query = Database::prepare($connection, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
  17. $result = Database::execute($connection, $query, null, null);
  18. if ($result===false) return false;
  19. return true;
  20. }
  21. }
  22. ?>