PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/system/classes/kohana/log/syslog.php

https://bitbucket.org/ekiwookie/juss
PHP | 64 lines | 24 code | 6 blank | 34 comment | 2 complexity | 71cd044063b210ebf74b5ca78c2b309f MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3. * Syslog log writer.
  4. *
  5. * @package Kohana
  6. * @category Logging
  7. * @author Jeremy Bush
  8. * @copyright (c) 2012 Kohana Team
  9. * @license http://kohanaframework.org/license
  10. */
  11. class Kohana_Log_Syslog extends Log_Writer {
  12. /**
  13. * @var string The syslog identifier
  14. */
  15. protected $_ident;
  16. /**
  17. * Creates a new syslog logger.
  18. *
  19. * @link http://www.php.net/manual/function.openlog
  20. *
  21. * @param string $ident syslog identifier
  22. * @param int $facility facility to log to
  23. * @return void
  24. */
  25. public function __construct($ident = 'KohanaPHP', $facility = LOG_USER)
  26. {
  27. $this->_ident = $ident;
  28. // Open the connection to syslog
  29. openlog($this->_ident, LOG_CONS, $facility);
  30. }
  31. /**
  32. * Writes each of the messages into the syslog.
  33. *
  34. * @param array $messages
  35. * @return void
  36. */
  37. public function write(array $messages)
  38. {
  39. foreach ($messages as $message)
  40. {
  41. if (Log::STRACE == $message['level'])
  42. {
  43. $message['level'] = Log::DEBUG;
  44. }
  45. syslog($message['level'], $message['body']);
  46. }
  47. }
  48. /**
  49. * Closes the syslog connection
  50. *
  51. * @return void
  52. */
  53. public function __destruct()
  54. {
  55. // Close connection to syslog
  56. closelog();
  57. }
  58. } // End Kohana_Log_Syslog