PluginProbe
DecaLog / 4.4.0
DecaLog v4.4.0
3.0.2 3.1.0 3.10.0 3.2.0 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.8.0 3.9.0 3.9.1 4.0.0 4.1.0 4.2.0 4.3.0 4.3.1 4.4.0 4.5.0 All 75 releases
decalog / includes / handlers / class-stackdriverhandler.php

class-stackdriverhandler.php in DecaLog 4.4.0, at includes/handlers/class-stackdriverhandler.php

54 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Stackdriver via Fluentd handler for Monolog
4 *
5 * Handles all features of Stackdriver via Fluentd handler for Monolog.
6 *
7 * @package Handlers
8 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
9 * @since 1.0.0
10 */
11
12 namespace Decalog\Handler;
13
14 use DLMonolog\Logger;
15 use Decalog\Plugin\Feature\DLogger;
16 use DLMonolog\Handler\SocketHandler;
17 use DLMonolog\Formatter\FormatterInterface;
18 use Decalog\Formatter\StackdriverFormatter;
19
20 /**
21 * Define the Monolog Stackdriver via Fluentd handler.
22 *
23 * Handles all features of Stackdriver via Fluentd handler for Monolog.
24 *
25 * @package Handlers
26 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
27 * @since 1.0.0
28 */
29 class StackdriverHandler extends SocketHandler {
30
31 /**
32 * @param string $connection_string Socket connection string.
33 * @param integer $timeout The socket timeout.
34 * @param int|string $level The minimum logging level at which this handler will be triggered.
35 * @param bool $bubble Whether the messages that are handled can bubble up the stack or not.
36 */
37 public function __construct( string $connection_string, int $timeout, $level = Logger::DEBUG, bool $bubble = true ) {
38 $new_timeout = $timeout / 1000;
39 $old_timeout = ini_get( 'default_socket_timeout' );
40 // phpcs:ignore
41 ini_set( 'default_socket_timeout', (string) $new_timeout );
42 parent::__construct( $connection_string, $level, $bubble );
43 // phpcs:ignore
44 ini_set( 'default_socket_timeout', (string) $old_timeout );
45 }
46
47 /**
48 * {@inheritDoc}
49 */
50 protected function getDefaultFormatter(): FormatterInterface {
51 return new StackdriverFormatter();
52 }
53 }
54