Skip to content

Commit

Permalink
Send JSON to syslog (#1424)
Browse files Browse the repository at this point in the history
* Send JSON to syslog

* Add changelog

Co-authored-by: Tom Fleming <[email protected]>
  • Loading branch information
weitzman and tom-fleming authored Mar 29, 2022
1 parent 24b654c commit b120e89
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
41 changes: 41 additions & 0 deletions changelogs/DP-24384.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Write your changelog entry here. Every pull request must have a changelog yml file.
#
# Change types:
# #############################################################################
# You can use one of the following types:
# - Added: For new features.
# - Changed: For changes to existing functionality.
# - Deprecated: For soon-to-be removed features.
# - Removed: For removed features.
# - Fixed: For any bug fixes.
# - Security: In case of vulnerabilities.
#
# Format
# #############################################################################
# The format is crucial. Please follow the examples below. For reference, the requirements are:
# - All 3 parts are required and you must include "Type", "description" and "issue".
# - "Type" must be left aligned and followed by a colon.
# - "description" must be indented with 2 spaces followed by a colon
# - "issue" must be indented with 4 spaces followed by a colon.
# - "issue" is for the Jira ticket number only e.g. DP-1234
# - No extra spaces, indents, or blank lines are allowed.
#
# Example:
# #############################################################################
# Fixed:
# - description: Fixes scrolling on edit pages in Safari.
# issue: DP-13314
#
# You may add more than 1 description & issue for each type using the following format:
# Changed:
# - description: Automating the release branch.
# issue: DP-10166
# - description: Second change item that needs a description.
# issue: DP-19875
# - description: Third change item that needs a description along with an issue.
# issue: DP-19843
#
Changed:
- description: Send JSON to syslog
issue: DP-24384
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\mass_utility\Logger;

use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\SyslogHandler;
use Monolog\Logger;

Expand All @@ -16,6 +16,7 @@
*/
class AcquiaSyslogHandler extends SyslogHandler {

// Was used when before we switched to JSONFormatter (3/2022).
const FORMAT = '%extra.base_url%|%extra.timestamp%|%channel%|%level_name%|%extra.ip%|%extra.request_uri%|%extra.referer%|%extra.uid%|%context.link%|%message%';

/**
Expand All @@ -30,7 +31,7 @@ public function __construct($facility = LOG_LOCAL0, $level = Logger::DEBUG, $bub
* {@inheritdoc}
*/
public function getDefaultFormatter(): FormatterInterface {
return new LineFormatter(self::FORMAT);
return new JsonFormatter();
}

/**
Expand Down

0 comments on commit b120e89

Please sign in to comment.