SVG to picture converter in PHP http://labs.shikiryu.com/svgtoimage/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.5 KiB

  1. <?php
  2. class Log
  3. {
  4. /** @var false|resource */
  5. protected $logfile;
  6. /**
  7. * Log constructor.
  8. * @param $filename
  9. */
  10. public function __construct($filename)
  11. {
  12. $file = $filename;
  13. $this->logfile = fopen($file, 'ab+');
  14. $this->message('Starting log');
  15. }
  16. /**
  17. * @param $message
  18. * @return false|int
  19. */
  20. public function message($message)
  21. {
  22. $message = '[' . date('Y-m-d / H:i:s') . '] @MESSAGE' . ' - ' . $message;
  23. $message .= "\n";
  24. return fwrite($this->logfile, $message);
  25. }
  26. /**
  27. * @param $message
  28. * @return false|int
  29. */
  30. public function error($message)
  31. {
  32. $message = '[' . date('Y-m-d / H:i:s') . '] @ERROR' . ' - ' . $message;
  33. $message .= "\n";
  34. return fwrite($this->logfile, $message);
  35. }
  36. /**
  37. *
  38. */
  39. public function __destruct()
  40. {
  41. $this->message("Finishing log\n-----------------------");
  42. fclose($this->logfile);
  43. }
  44. /**
  45. * @param mixed $message
  46. * @return string
  47. */
  48. public static function decode($message)
  49. {
  50. if (is_string($message)) {
  51. return $message;
  52. }
  53. if (is_array($message)) {
  54. return implode('|', $message);
  55. }
  56. if ($message instanceof SimpleXMLElement) {
  57. return (string) $message;
  58. }
  59. return '';
  60. }
  61. }