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 / features / class-handlerdiagnosis.php

class-handlerdiagnosis.php in DecaLog 4.4.0, at includes/features/class-handlerdiagnosis.php

94 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Logger types diagnosis
4 *
5 * Diagnose all available logger types.
6 *
7 * @package Features
8 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
9 * @since 1.0.0
10 */
11
12 namespace Decalog\Plugin\Feature;
13
14 /**
15 * Define the logger types diagnosis.
16 *
17 * Diagnose all available logger types.
18 *
19 * @package Features
20 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
21 * @since 1.0.0
22 */
23 class HandlerDiagnosis {
24
25 /**
26 * Initialize the class and set its properties.
27 *
28 * @since 1.0.0
29 */
30 public function __construct() {
31 }
32
33 /**
34 * Check if a handler is usable.
35 *
36 * @param string $handler The class name of the handler to verify.
37 * @return boolean True if handler can be used, false otherwise.
38 * @since 1.0.0
39 */
40 public function check( $handler ) {
41 $result = true;
42 $method = 'check_' . strtolower( $handler );
43 if ( method_exists( $this, $method ) ) {
44 $result = call_user_func( [ $this, $method ] );
45 }
46 return $result;
47 }
48
49 /**
50 * Get error string.
51 *
52 * @param string $handler The class name of the handler to verify.
53 * @return string The error in plain text.
54 * @since 1.0.0
55 */
56 public function error_string( $handler ) {
57 $result = '';
58 $method = 'error_string_' . strtolower( $handler );
59 if ( method_exists( $this, $method ) ) {
60 $result = call_user_func( [ $this, $method ] );
61 }
62 return $result;
63 }
64
65 /**
66 * Check if SyslogUdpHandler is usable.
67 *
68 * @return boolean True if SyslogUdpHandler can be used, false otherwise.
69 * @since 1.0.0
70 */
71 public function check_syslogudphandler() {
72 $result = true;
73 if ( ! function_exists( 'socket_create' ) ) {
74 $result = false;
75 }
76 return $result;
77 }
78
79 /**
80 * Get error string for SyslogUdpHandler.
81 *
82 * @return string The error in plain text.
83 * @since 1.0.0
84 */
85 public function error_string_syslogudphandler() {
86 $result = '';
87 if ( ! function_exists( 'socket_create' ) ) {
88 $result = 'PHP support for sockets is not installed.';
89 }
90 return $result;
91 }
92
93 }
94