/classes/woocommerce-quickpay-log.php

  1. <?php 
  2. /** 
  3. * WC_QuickPay_Log class 
  4. * 
  5. * @class WC_QuickPay_Log 
  6. * @since 4.0.0 
  7. * @package Woocommerce_QuickPay/Classes 
  8. * @category Logs 
  9. * @author PerfectSolution 
  10. */ 
  11. class WC_QuickPay_Log { 
  12.  
  13. /** The domain handler used to name the log */ 
  14. private $_domain = 'woocommerce-quickpay'; 
  15.  
  16.  
  17. /** The WC_Logger instance */ 
  18. private $_logger; 
  19.  
  20.  
  21. /** 
  22. * __construct. 
  23. * 
  24. * @access public  
  25. * @return void 
  26. */  
  27. public function __construct()  
  28. $this->_logger = new WC_Logger(); 
  29.  
  30.  
  31. /** 
  32. * add function. 
  33. * 
  34. * Uses the build in logging method in WooCommerce. 
  35. * Logs are available inside the System status tab 
  36. * 
  37. * @access public  
  38. * @param string|array|object 
  39. * @return void 
  40. */  
  41. public function add( $param )  
  42. if( is_array( $param ) ) { 
  43. $param = print_r( $param, TRUE );  
  44.  
  45. $this->_logger->add( $this->_domain, $param ); 
  46.  
  47.  
  48. /** 
  49. * clear function. 
  50. * 
  51. * Clears the entire log file 
  52. * 
  53. * @access public  
  54. * @return void 
  55. */  
  56. public function clear()  
  57. return $this->_logger->clear( $this->_domain ); 
  58.  
  59.  
  60. /** 
  61. * separator function. 
  62. * 
  63. * Inserts a separation line for better overview in the logs. 
  64. * 
  65. * @access public  
  66. * @return void 
  67. */  
  68. public function separator()  
  69. $this->add( '--------------------' );  
  70.  
  71.  
  72. /** 
  73. * get_domain function. 
  74. * 
  75. * Returns the log text domain 
  76. * 
  77. * @access public  
  78. * @return string 
  79. */  
  80. public function get_domain()  
  81. return $this->_domain; 
  82.  
  83. /** 
  84. * Returns a link to the log files in the WP backend. 
  85. */ 
  86. public function get_admin_link() { 
  87. $log_path = wc_get_log_file_path($this->_domain); 
  88. $log_path_parts = explode('/', $log_path); 
  89. return add_query_arg(array( 
  90. 'page' => 'wc-status',  
  91. 'tab' => 'logs',  
  92. 'log_file' => end($log_path_parts) 
  93. ), admin_url('admin.php')); 
.