WP Manifestindependent plugin directory
manifest / developer / mgc-logger

MGC Logger

Simple logger class for wordpress

★ 1stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/minkaizen/mgc-logger/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Description

Simple class for creating logs in wordpress

Quickstart

use \MGC\Logger\Logger;

$logger = new Logger( 'my-subdirectory', 'sales.log' );
$logger->log( 'Test log message' );
$logger->log( 'Another message' );

Output:

# in {path to uploads folder}/my-subdirectory

2020-01-01 12:30: Test log message
2020-01-01 12:30: Another message

Debugging

Use get_test_log() to print debug information:

use \MGC\Logger\Logger;

$logger = new Logger( 'my-subdirectory', 'sales.log' );
print_r( $logger->get_test_log( 'Test log message' ) );

Output:

Array()
  [log_directory] => "{path to uploads folder}/my-subdirectory"
  [log_directory_exists] => true,
  [log_file] => "{path to uploads folder}/my-subdirectory/sales.log"
  [log_file_exists] => false,
  [base_message] => "Test log message",
  [tags] => Array(),
  [final_message] => "2020-01-01 12:30: Test log message",