PluginProbe ʕ •ᴥ•ʔ
TaxCloud for WooCommerce / 8.4.11
TaxCloud for WooCommerce v8.4.11
8.4.11 8.4.10 8.4.9 trunk 6.0.11 6.0.12 6.0.13 6.0.14 6.1.0 6.1.1 6.1.2 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.13 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.0 7.0.1 7.0.10 7.0.11 7.0.12 7.0.13 7.0.2 7.0.3 7.0.4 7.0.5 7.0.6 7.0.7 7.0.8 7.0.9 8.0.0 8.0.1 8.0.10 8.0.11 8.0.12 8.0.13 8.0.14 8.0.15 8.0.16 8.0.17 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.0.9 8.1.0 8.1.1 8.2.0 8.2.1 8.2.2 8.2.3 8.2.4 8.3.0 8.3.1 8.3.2 8.3.3 8.3.4 8.3.5 8.3.6 8.3.7 8.3.8 8.4.0 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.4.6 8.4.7 8.4.8
simple-sales-tax / includes / class-sst-logger.php
simple-sales-tax / includes Last commit date
abstracts 3 months ago admin 3 months ago frontend 1 month ago integrations 1 month ago v3 3 months ago vendor 6 days ago views 8 months ago class-simplesalestax.php 6 days ago class-sst-addresses.php 1 month ago class-sst-ajax.php 3 months ago class-sst-assets.php 6 months ago class-sst-blocks-integration.php 1 month ago class-sst-blocks.php 1 year ago class-sst-certificates.php 6 days ago class-sst-install.php 6 months ago class-sst-logger.php 5 months ago class-sst-marketplaces.php 6 months ago class-sst-order-controller.php 3 months ago class-sst-order.php 1 month ago class-sst-origin-address.php 8 months ago class-sst-product.php 3 months ago class-sst-rate-limit.php 5 months ago class-sst-settings.php 3 months ago class-sst-shipping.php 3 years ago class-sst-taxcloud-v3-api.php 3 months ago class-sst-taxcloud-v3.php 3 months ago class-sst-tic.php 2 years ago class-sst-updater.php 3 years ago sst-compatibility-functions.php 4 months ago sst-functions.php 6 days ago sst-message-functions.php 3 years ago sst-update-functions.php 11 months ago
class-sst-logger.php
134 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly.
5 }
6
7 /**
8 * Logger.
9 *
10 * Used for logging error messages.
11 *
12 * @author Simple Sales Tax
13 * @package SST
14 * @since 5.0
15 */
16 class SST_Logger {
17
18 /**
19 * Log handle.
20 *
21 * @var string
22 * @since 5.0
23 */
24 protected static $handle = 'wootax';
25
26 /**
27 * Logger instance.
28 *
29 * @var WC_Logger
30 * @since 5.0
31 */
32 protected static $logger = null;
33
34 /**
35 * Initialize the logger instance.
36 *
37 * @since 5.0
38 */
39 public static function init() {
40 if ( 'yes' === SST_Settings::get( 'log_requests' ) ) {
41 /**
42 * Create a new log file every day.
43 */
44 self::$handle = self::$handle . '-' . gmdate( 'Y-m-d' );
45 self::$logger = function_exists( 'wc_get_logger' ) ? wc_get_logger() : new WC_Logger();
46 }
47 }
48
49 /**
50 * Get log file path.
51 *
52 * @return string
53 * @since 5.0
54 */
55 public static function get_log_path() {
56 return wc_get_log_file_path( self::$handle );
57 }
58
59 /**
60 * Add a log entry.
61 *
62 * @param string $message Log message.
63 *
64 * @since 5.0
65 */
66 public static function add( $message, $context = array() ) {
67 if ( ! is_null( self::$logger ) ) {
68 self::$logger->notice( $message, array(
69 'source' => self::$handle,
70 '_context' => (array) $context
71 )
72 );
73 }
74 }
75
76
77 /**
78 * Log a debug message.
79 *
80 * @param string $message Log message.
81 * @param array $context Log context.
82 *
83 * @since 8.3.4
84 */
85 public static function debug( $message, $context = array() ) {
86 if ( ! is_null( self::$logger ) ) {
87 self::$logger->debug( $message, array(
88 'source' => self::$handle,
89 '_context' => (array) $context
90 )
91 );
92 }
93 }
94
95 /**
96 * Log an order message.
97 *
98 * @param string $message Log message.
99 * @param array $context Log context.
100 *
101 * @since 8.3.4
102 */
103 public static function order_log( $message, $order_id, $context = array() ) {
104 if ( ! is_null( self::$logger ) ) {
105 self::$logger->debug( $message, array(
106 'source' => 'wootax-order-' . $order_id,
107 '_context' => (array) $context
108 )
109 );
110 }
111 }
112
113 /**
114 * Log an error message.
115 *
116 * @param string $message Log message.
117 * @param array $context Log context.
118 *
119 * @since 8.4.2
120 */
121 public static function error( $message, $context = array() ) {
122 if ( ! is_null( self::$logger ) ) {
123 self::$logger->error( $message, array(
124 'source' => self::$handle,
125 '_context' => (array) $context
126 )
127 );
128 }
129 }
130
131 }
132
133 SST_Logger::init();
134