PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.4
Pods – Custom Content Types and Fields v2.8.23.4
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / tribe-common / src / Tribe / Log / Action_Logger.php
pods / tribe-common / src / Tribe / Log Last commit date
Action_Logger.php 2 weeks ago Admin.php 2 weeks ago Canonical_Formatter.php 2 weeks ago File_Logger.php 2 weeks ago Logger.php 2 weeks ago Monolog_Logger.php 2 weeks ago Null_Logger.php 2 weeks ago Service_Provider.php 2 weeks ago
Action_Logger.php
126 lines
1 <?php
2 /**
3 * Hooks the `tribe_log` action based logger under the existing one for back-compatibility.
4 *
5 * @since 4.9.16
6 *
7 * @package Tribe\Log
8 */
9
10 namespace Tribe\Log;
11
12 use Monolog\Logger;
13 use Tribe__Log;
14
15 /**
16 * Class Action_Logger
17 *
18 * @since 4.9.16
19 *
20 * @package Tribe\Log
21 */
22 class Action_Logger implements \Tribe__Log__Logger {
23
24 /**
25 * {@inheritDoc}
26 *
27 * @since 4.9.16
28 */
29 public function is_available() {
30 return true;
31 }
32
33 /**
34 * {@inheritDoc}
35 *
36 * @since 4.9.16
37 */
38 public function get_name() {
39 return __( 'Action-based Logger', 'tribe-common' );
40 }
41
42 /**
43 * {@inheritDoc}
44 *
45 * @since 4.9.16
46 */
47 public function log( $entry, $type = Tribe__Log::DEBUG, $src = '' ) {
48 $message = empty( $src ) ? $entry : $src . ': ' . $entry;
49
50 do_action( 'tribe_log', $this->translate_log_level( $type ), $message );
51 }
52
53 /**
54 * Translates the log types used by `Tribe__Log` to those used by Monolog.
55 *
56 * @since 4.9.16
57 *
58 * @param string $type The `Tribe__Log` log type.
59 *
60 * @return int The Monolog equivalent of the current level.
61 */
62 protected function translate_log_level( $type ) {
63 switch ( $type ) {
64 case Tribe__Log::DEBUG:
65 return Logger::DEBUG;
66 case Tribe__Log::ERROR:
67 return Logger::ERROR;
68 case Tribe__Log::WARNING:
69 return Logger::WARNING;
70 case Tribe__Log::SUCCESS:
71 default:
72 return Logger::INFO;
73 }
74 }
75
76 /**
77 * {@inheritDoc}
78 *
79 * @since 4.9.16
80 */
81 public function retrieve( $limit = 0, array $args = [] ) {
82 return [
83 [
84 'message' => __(
85 'The Action Logger will dispatch any logging message using the "tribe_log" action writing, by ' .
86 'default, to the PHP error log.',
87 'tribe-common' )
88 ],
89 ];
90 }
91
92 /**
93 * {@inheritDoc}
94 *
95 * @since 4.9.16
96 */
97 public function list_available_logs() {
98 return [];
99 }
100
101 /**
102 * Changes the Monolog logger channel to the specified one.
103 *
104 * @since 4.9.16
105 *
106 * @param string $log_identifier The channel to switch to.
107 * @param bool $create Unused by this class.
108 *
109 * @return bool The exit status of the channel change.
110 *
111 * @uses \Tribe\Log\Monolog_Logger::set_channel().
112 */
113 public function use_log( $log_identifier, $create = false ) {
114 return tribe( 'monolog' )->set_global_channel( $log_identifier );
115 }
116
117 /**
118 * {@inheritDoc}
119 *
120 * @since 4.9.16
121 */
122 public function cleanup() {
123 return true;
124 }
125 }
126