[PR #4] [MERGED] add new SyslogHandler class #868

Closed
opened 2026-03-04 03:02:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Seldaek/monolog/pull/4
Author: @subsven
Created: 3/22/2011
Status: Merged
Merged: 3/23/2011
Merged by: @Seldaek

Base: masterHead: master


📝 Commits (2)

  • d9d0f51 add SyslogHandler to Monolog
  • 38a4ddf remove LOG_NDELAY from the openlog() call since the expected behaviour

📊 Changes

2 files changed (+130 additions, -0 deletions)

View changed files

src/Monolog/Handler/SyslogHandler.php (+93 -0)
tests/Monolog/Handler/SyslogHandlerTest.php (+37 -0)

📄 Description

Since there is currently no syslog support in Monolog (and it even was on your todo list :-) ) here is a new SyslogHandler class.

A basic usage example:

   $log = new Logger('application');
   $syslog = new SyslogHandler('myfacility', 'local6');
   $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%");
   $syslog->setFormatter($formatter);
   $log->pushHandler($syslog);

The special formatter is needed since the timestamp is included automatically in all syslog messages.
The facility can be given using PHP constants (LOG_LOCAL5) or by string ('local5') to simplify setting the values from a configuration file.

I couldn't think of any unit test approaches for actually writing the message since mocking the syslog() function isn't possible and all tests using the real syslog() function would depend on a special syslogd configuration. So currently the unit tests only cover the constructor.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Seldaek/monolog/pull/4 **Author:** [@subsven](https://github.com/subsven) **Created:** 3/22/2011 **Status:** ✅ Merged **Merged:** 3/23/2011 **Merged by:** [@Seldaek](https://github.com/Seldaek) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (2) - [`d9d0f51`](https://github.com/Seldaek/monolog/commit/d9d0f5123877d9d5ff5c56b48aa99e69d9e606a7) add SyslogHandler to Monolog - [`38a4ddf`](https://github.com/Seldaek/monolog/commit/38a4ddf9f26951f9d34a712826be010b1162073a) remove LOG_NDELAY from the openlog() call since the expected behaviour ### 📊 Changes **2 files changed** (+130 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `src/Monolog/Handler/SyslogHandler.php` (+93 -0) ➕ `tests/Monolog/Handler/SyslogHandlerTest.php` (+37 -0) </details> ### 📄 Description Since there is currently no syslog support in Monolog (and it even was on your todo list :-) ) here is a new SyslogHandler class. A basic usage example: ``` $log = new Logger('application'); $syslog = new SyslogHandler('myfacility', 'local6'); $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%"); $syslog->setFormatter($formatter); $log->pushHandler($syslog); ``` The special formatter is needed since the timestamp is included automatically in all syslog messages. The facility can be given using PHP constants (LOG_LOCAL5) or by string ('local5') to simplify setting the values from a configuration file. I couldn't think of any unit test approaches for actually writing the message since mocking the syslog() function isn't possible and all tests using the real syslog() function would depend on a special syslogd configuration. So currently the unit tests only cover the constructor. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 03:02:07 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#868
No description provided.