| 1 |
<?php |
| 2 |
/** |
| 3 |
* Log.php |
| 4 |
* |
| 5 |
* @package CTXFeed |
| 6 |
* @subpackage Disco\App\Utility |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Disco\App\Utility; |
| 10 |
|
| 11 |
use WC_Logger; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class Log |
| 15 |
* |
| 16 |
* @package CTXFeed |
| 17 |
* @subpackage Disco\App\Utility |
| 18 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 19 |
* @link https://webappick.com |
| 20 |
* @license https://opensource.org/licenses/gpl-license.php GNU Public License |
| 21 |
* @category MyCategory |
| 22 |
*/ |
| 23 |
class Log { |
| 24 |
|
| 25 |
/** |
| 26 |
* Write log to WooCommerce log file. |
| 27 |
* |
| 28 |
* @param string $message Message to write to log. |
| 29 |
* @param string $type Type of log. |
| 30 |
* @return void |
| 31 |
*/ |
| 32 |
public static function write( $message, $type = 'info' ) { |
| 33 |
if ( ! class_exists( 'WC_Logger' ) ) { |
| 34 |
return; |
| 35 |
} |
| 36 |
|
| 37 |
$handle = DISCO_TEXTDOMAIN; |
| 38 |
$log = new WC_Logger( array( $handle ) ); |
| 39 |
|
| 40 |
if ( $type === 'error' ) { |
| 41 |
$log->error( $message ); |
| 42 |
} elseif ( $type === 'warning' ) { |
| 43 |
$log->warning( $message ); |
| 44 |
} elseif ( $type === 'info' ) { |
| 45 |
$log->info( $message ); |
| 46 |
} else { |
| 47 |
$log->add( $handle, $message ); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
|