Log.php 954 B

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