PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/Ahineya/trn_dev
PHP | 70 lines | 26 code | 7 blank | 37 comment | 0 complexity | 985bffec809adfb8ae74ef9900af11c5 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) 2010 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. * @var array log levels
  18. */
  19. protected $_syslog_levels = array('ERROR' => LOG_ERR,
  20. 'CRITICAL' => LOG_CRIT,
  21. 'STRACE' => LOG_ALERT,
  22. 'ALERT' => LOG_WARNING,
  23. 'INFO' => LOG_INFO,
  24. 'DEBUG' => LOG_DEBUG);
  25. /**
  26. * Creates a new syslog logger.
  27. *
  28. * @see http://us2.php.net/openlog
  29. *
  30. * @param string syslog identifier
  31. * @param int facility to log to
  32. * @return void
  33. */
  34. public function __construct($ident = 'KohanaPHP', $facility = LOG_USER)
  35. {
  36. $this->_ident = $ident;
  37. // Open the connection to syslog
  38. openlog($this->_ident, LOG_CONS, $facility);
  39. }
  40. /**
  41. * Writes each of the messages into the syslog.
  42. *
  43. * @param array messages
  44. * @return void
  45. */
  46. public function write(array $messages)
  47. {
  48. foreach ($messages as $message)
  49. {
  50. syslog($message['level'], $message['body']);
  51. }
  52. }
  53. /**
  54. * Closes the syslog connection
  55. *
  56. * @return void
  57. */
  58. public function __destruct()
  59. {
  60. // Close connection to syslog
  61. closelog();
  62. }
  63. } // End Kohana_Log_Syslog