WooCommerce Code Reference
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • WooCommerce Docs
  • REST API Docs

Packages

  • None
  • WooCommerce
    • Abstracts
    • Admin
      • Customize
      • Functions
      • Importers
      • Meta
      • Reports
      • System
    • API
    • Classes
      • Data
        • Store
      • Emails
      • Embed
      • Integrations
      • Interfaces
      • Log
        • Handlers
      • Payment
      • Products
      • Shipping
      • Walkers
    • Export
    • Functions
    • Import
    • l10n
    • PaymentTokens
    • PayPal
    • Shortcodes
      • Cart
      • Checkout
      • My
        • Account
      • Order
        • Tracking
    • Webhooks
    • Widgets
  • WP-Background-Processing

Classes

  • Abstract_WC_Order_Data_Store_CPT
  • WC_Abstract_Order
  • WC_AJAX
  • WC_Autoloader
  • WC_Background_Emailer
  • WC_Background_Process
  • WC_Background_Updater
  • WC_Breadcrumb
  • WC_Cache_Helper
  • WC_Cart
  • WC_Cart_Fees
  • WC_Cart_Session
  • WC_Cart_Totals
  • WC_Checkout
  • WC_Coupon
  • WC_Customer
  • WC_Customer_Download
  • WC_Customer_Download_Log
  • WC_DateTime
  • WC_Discounts
  • WC_Download_Handler
  • WC_Geo_IP
  • WC_Geo_IP_Record
  • WC_Geolocation
  • WC_HTTPS
  • WC_Install
  • WC_Legacy_Cart
  • WC_Legacy_Coupon
  • WC_Legacy_Customer
  • WC_Legacy_Payment_Token
  • WC_Legacy_Shipping_Zone
  • WC_Legacy_Webhook
  • WC_Log_Levels
  • WC_Logger
  • WC_Order
  • WC_Order_Data_Store_CPT
  • WC_Order_Factory
  • WC_Order_Item
  • WC_Order_Item_Coupon
  • WC_Order_Item_Fee
  • WC_Order_Item_Meta
  • WC_Order_Item_Product
  • WC_Order_Item_Shipping
  • WC_Order_Item_Tax
  • WC_Order_Query
  • WC_Order_Refund
  • WC_Payment_Gateway_CC
  • WC_Payment_Gateway_eCheck
  • WC_Payment_Tokens
  • WC_Product_Attribute
  • WC_Product_Data_Store_CPT
  • WC_Product_Download
  • WC_Product_Factory
  • WC_Product_Query
  • WC_Product_Variable_Data_Store_CPT
  • WC_Product_Variation
  • WC_Query
  • WC_Regenerate_Images
  • WC_Regenerate_Images_Request
  • WC_Register_WP_Admin_Settings
  • WC_Session_Handler
  • WC_Shipping_Zone
  • WC_Shipping_Zones
  • WC_Shortcodes
  • WC_Structured_Data
  • WC_Tax
  • WC_Template_Loader
  • WC_Tracker
  • WC_Twenty_Eleven
  • WC_Twenty_Fifteen
  • WC_Twenty_Fourteen
  • WC_Twenty_Seventeen
  • WC_Twenty_Sixteen
  • WC_Twenty_Ten
  • WC_Twenty_Thirteen
  • WC_Twenty_Twelve
  • WC_Validation

Class WC_Logger

Provides logging capabilities for debugging purposes.

WC_Logger implements WC_Logger_Interface
Package: WooCommerce\Classes
Category: Class
Author: WooThemes
Version: 2.0.0
Class: WC_Logger
Located at class-wc-logger.php

Methods summary

public
# __construct( array $handlers = null, string $threshold = null )

Constructor for the logger.

Constructor for the logger.

Parameters

$handlers

Optional. Array of log handlers. If $handlers is not provided, the filter 'woocommerce_register_log_handlers' will be used to define the handlers. If $handlers is provided, the filter will not be applied and the handlers will be used directly.

$threshold

Optional. Define an explicit threshold. May be configured via WC_LOG_THRESHOLD. By default, all logs will be processed.

protected boolean
# should_handle( string $level )

Determine whether to handle or ignore log.

Determine whether to handle or ignore log.

Parameters

$level
emergency|alert|critical|error|warning|notice|info|debug

Returns

boolean
True if the log should be handled.
public boolean
# add( string $handle, string $message, string $level = WC_Log_Levels::NOTICE )

Add a log entry.

Add a log entry.

This is not the preferred method for adding log messages. Please use log() or any one of the level methods (debug(), info(), etc.). This method may be deprecated in the future.

Parameters

$handle
$message
$level

Returns

boolean

Implementation of

WC_Logger_Interface::add()
public
# log( string $level, string $message, array $context = array() )

Add a log entry.

Add a log entry.

Parameters

$level

One of the following: 'emergency': System is unusable. 'alert': Action must be taken immediately. 'critical': Critical conditions. 'error': Error conditions. 'warning': Warning conditions. 'notice': Normal but significant condition. 'info': Informational messages. 'debug': Debug-level messages.

$message
Log message.
$context
Optional. Additional information for log handlers.

Implementation of

WC_Logger_Interface::log()
public
# emergency( string $message, array $context = array() )

Adds an emergency level message.

Adds an emergency level message.

System is unusable.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::emergency()
public
# alert( string $message, array $context = array() )

Adds an alert level message.

Adds an alert level message.

Action must be taken immediately. Example: Entire website down, database unavailable, etc.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::alert()
public
# critical( string $message, array $context = array() )

Adds a critical level message.

Adds a critical level message.

Critical conditions. Example: Application component unavailable, unexpected exception.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::critical()
public
# error( string $message, array $context = array() )

Adds an error level message.

Adds an error level message.

Runtime errors that do not require immediate action but should typically be logged and monitored.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::error()
public
# warning( string $message, array $context = array() )

Adds a warning level message.

Adds a warning level message.

Exceptional occurrences that are not errors.

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::warning()
public
# notice( string $message, array $context = array() )

Adds a notice level message.

Adds a notice level message.

Normal but significant events.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::notice()
public
# info( string $message, array $context = array() )

Adds a info level message.

Adds a info level message.

Interesting events. Example: User logs in, SQL logs.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::info()
public
# debug( string $message, array $context = array() )

Adds a debug level message.

Adds a debug level message.

Detailed debug information.

Parameters

$message
$context

See

WC_Logger::log

Implementation of

WC_Logger_Interface::debug()
public boolean
# clear( string $handle )

Clear entries from chosen file.

Clear entries from chosen file.

Deprecated

3.0.0

Parameters

$handle

Returns

boolean

Properties summary

protected array $handlers

Stores registered log handlers.

Stores registered log handlers.

#
protected integer $threshold

Minimum log level this handler will process.

Minimum log level this handler will process.

#
WooCommerce Code Reference API documentation generated by ApiGen