Skip to content

Commit 9f0515c

Browse files
eriklundinnikic
authored andcommitted
Add syslog.filter=raw
This passes through syslog message unchanged, without splitting messages at newlines.
1 parent 96a6f7f commit 9f0515c

File tree

6 files changed

+17
-0
lines changed

6 files changed

+17
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.3.8
44

5+
- Core:
6+
. Added syslog.filter=raw option. (Erik Lundin)
7+
58
- Opcache:
69
. Fixed bug #78106 (Path resolution fails if opcache disabled during request).
710
(Nikita)

main/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ static PHP_INI_MH(OnSetLogFilter)
346346
PG(syslog_filter) = PHP_SYSLOG_FILTER_ASCII;
347347
return SUCCESS;
348348
}
349+
if (!strcmp(filter, "raw")) {
350+
PG(syslog_filter) = PHP_SYSLOG_FILTER_RAW;
351+
return SUCCESS;
352+
}
349353

350354
return FAILURE;
351355
}

main/php_syslog.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
7777
smart_string_0(&fbuf);
7878
va_end(args);
7979

80+
if (PG(syslog_filter) == PHP_SYSLOG_FILTER_RAW) {
81+
/* Just send it directly to the syslog */
82+
syslog(priority, "%.*s", (int)fbuf.len, fbuf.c);
83+
smart_string_free(&fbuf);
84+
return;
85+
}
86+
8087
for (ptr = fbuf.c; ; ++ptr) {
8188
c = *ptr;
8289
if (c == '\0') {

main/php_syslog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define PHP_SYSLOG_FILTER_ALL 0
3535
#define PHP_SYSLOG_FILTER_NO_CTRL 1
3636
#define PHP_SYSLOG_FILTER_ASCII 2
37+
#define PHP_SYSLOG_FILTER_RAW 3
3738

3839
BEGIN_EXTERN_C()
3940
PHPAPI void php_syslog(int, const char *format, ...);

php.ini-development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ html_errors = On
596596
; ascii (all printable ASCII characters and NL)
597597
; no-ctrl (all characters except control characters)
598598
; all (all characters)
599+
; raw (like "all", but messages are not split at newlines)
599600
; http://php.net/syslog.filter
600601
;syslog.filter = ascii
601602

php.ini-production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ html_errors = On
603603
; ascii (all printable ASCII characters and NL)
604604
; no-ctrl (all characters except control characters)
605605
; all (all characters)
606+
; raw (like "all", but messages are not split at newlines)
606607
; http://php.net/syslog.filter
607608
;syslog.filter = ascii
608609

0 commit comments

Comments
 (0)