Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wp-smush.../core/external/wdev-log...
File: README.md
# WDEV Logger #
[0] Fix | Delete
[1] Fix | Delete
WPMU DEV Logger - A simple logger module.
[2] Fix | Delete
[3] Fix | Delete
It's created based on Hummingbird\Core\Logger.
[4] Fix | Delete
This logger lib will handle the old messages based on the expected size.
[5] Fix | Delete
This means, it will try to get rid of the old messages if the file size is larger than the max size of the log file.
[6] Fix | Delete
[7] Fix | Delete
# How to use it #
[8] Fix | Delete
[9] Fix | Delete
1. Insert this repository as **sub-module** into the existing project
[10] Fix | Delete
[11] Fix | Delete
2. Include the file `wdev-logger.php` in your main plugin file.
[12] Fix | Delete
[13] Fix | Delete
3. Register a logger instance via method: WDEV_Logger::create
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
## Code Example ##
[17] Fix | Delete
[18] Fix | Delete
```
[19] Fix | Delete
#!php
[20] Fix | Delete
[21] Fix | Delete
<?php
[22] Fix | Delete
// Load the WDEV Logger module.
[23] Fix | Delete
include_once 'lib/wdev-logger/wdev-logger.php';
[24] Fix | Delete
[25] Fix | Delete
$logger = WDEV_Logger::create(array(
[26] Fix | Delete
'max_log_size' => 10,//10MB
[27] Fix | Delete
'expected_log_size_in_percent' => 0.7,//70%
[28] Fix | Delete
'log_dir' => 'uploads/your_plugin_name',
[29] Fix | Delete
'add_subsite_dir' => true,//For MU site, @see self::get_log_directory(),
[30] Fix | Delete
'is_private' => false,
[31] Fix | Delete
'modules' => array(
[32] Fix | Delete
'foo' => array(
[33] Fix | Delete
'is_private' => true,//-log.php,
[34] Fix | Delete
'log_dir' => 'uploads/specific/log_dir',
[35] Fix | Delete
),
[36] Fix | Delete
//uploads/your_plugin_name/bazz-debug.log
[37] Fix | Delete
'baz' => array(
[38] Fix | Delete
'name' => 'bazz',
[39] Fix | Delete
'max_log_size' => 5,//5MB,
[40] Fix | Delete
),
[41] Fix | Delete
//It's not required to register a main module, by default it will be index ($logger->index()->...)
[42] Fix | Delete
'main_module' => array(
[43] Fix | Delete
'is_global_module' => true,
[44] Fix | Delete
'log_level' => LOG_DEBUG,// @see self::$log_level
[45] Fix | Delete
)
[46] Fix | Delete
)
[47] Fix | Delete
), $your_plugin_key_or_null);
[48] Fix | Delete
// We will use this name ($your_plugin_key_or_null) to save the settings, we can leave it empty to use the folder plugin name.
[49] Fix | Delete
// @see WDEV_Logger::get_option_key() for more detail.
[50] Fix | Delete
[51] Fix | Delete
$logger->foo()->error('Log an error.');// result: [...DATE...] Error: Log an error. File path: [uploads/specific/log_dir/foo-log.php]
[52] Fix | Delete
$logger->foo()->warning('Log a warning');
[53] Fix | Delete
$logger->foo()->notice('Log a notice');
[54] Fix | Delete
$logger->foo()->info('Log info');
[55] Fix | Delete
//Main Module.
[56] Fix | Delete
$logger->main_module()->error('Log an error for main module');
[57] Fix | Delete
//Or
[58] Fix | Delete
$logger->error('Log an error');
[59] Fix | Delete
[60] Fix | Delete
//Delete log file.
[61] Fix | Delete
$logger->foo()->delete();//Delete the log file of module Foo.
[62] Fix | Delete
$logger->delete();//Delete log file for the main module.
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* By default, Logger only log when the user enable WP_DEBUG_LOG, but we can overwrite it via setting
[66] Fix | Delete
* or via methods.
[67] Fix | Delete
*
[68] Fix | Delete
* 1. Log mode:
[69] Fix | Delete
* define('WP_DEBUG_LOG', LOG_DEBUG );
[70] Fix | Delete
*
[71] Fix | Delete
* LOG_ERR or 3 => Only log Error type.
[72] Fix | Delete
* LOG_WARNING or 4 => Only log Warning type.
[73] Fix | Delete
* LOG_NOTICE or 5 => Only log Notice type.
[74] Fix | Delete
* LOG_INFO or 6 => Only log Info type.
[75] Fix | Delete
* LOG_DEBUG or 7 => Log Error, Warning and Notice type.
[76] Fix | Delete
* self::WPMUDEV_DEBUG_LEVEL or 10 or TRUE => for all message types.
[77] Fix | Delete
*/
[78] Fix | Delete
// or set log mode via set_log_level();
[79] Fix | Delete
$logger->set_log_level( LOG_DEBUG );// It will set for global module, and other modules can inherit from global module.
[80] Fix | Delete
// We can do like this to only activate it for the main module.
[81] Fix | Delete
$logger->main_module()->set_log_level( true );// While setting the log level via method, we will convert true to WPMUDEV_DEBUG_LEVEL.
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* 2. Debug mode.
[85] Fix | Delete
* define('WP_DEBUG', LOG_DEBUG );
[86] Fix | Delete
*
[87] Fix | Delete
* We use this config to enable option to log the backtrace:
[88] Fix | Delete
* LOG_ERR or 3 => Only for Error type.
[89] Fix | Delete
* LOG_WARNING or 4 => Only for Warning type.
[90] Fix | Delete
* LOG_NOTICE or 5 => Only for Notice type.
[91] Fix | Delete
* LOG_INFO or 6 => Only for Info type.
[92] Fix | Delete
* LOG_DEBUG or 7 => For Error, Warning and Notice type.
[93] Fix | Delete
* self::WPMUDEV_DEBUG_LEVEL or 10 => for all message types.
[94] Fix | Delete
*
[95] Fix | Delete
* Or via method.
[96] Fix | Delete
*/
[97] Fix | Delete
$logger->set_debug_level( LOG_DEBUG );
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Add a new module.
[101] Fix | Delete
*/
[102] Fix | Delete
[103] Fix | Delete
$logger->add_module('new-module', array(
[104] Fix | Delete
'is_private' => true,
[105] Fix | Delete
'log_level' => LOG_DEBUG
[106] Fix | Delete
));
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Update a module (it will also inherit from the old module option)
[110] Fix | Delete
* @see WDEV_Logger::update_module()
[111] Fix | Delete
*/
[112] Fix | Delete
[113] Fix | Delete
$logger->update_module('exist-module', array(
[114] Fix | Delete
'is_private' => true,
[115] Fix | Delete
'log_level' => LOG_DEBUG,
[116] Fix | Delete
'max_log_size' => 5,
[117] Fix | Delete
));
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Get the download link
[121] Fix | Delete
*/
[122] Fix | Delete
[123] Fix | Delete
$download_link_foo_log = $logger->foo()->get_download_link();
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Delete the log file via ajax.
[127] Fix | Delete
*/
[128] Fix | Delete
[129] Fix | Delete
add_action( 'admin_footer', 'wpmudev_logger_ajax' ); // Write our JS below here
[130] Fix | Delete
[131] Fix | Delete
function wpmudev_logger_ajax() {
[132] Fix | Delete
?>
[133] Fix | Delete
<script type="text/javascript" >
[134] Fix | Delete
jQuery(document).ready(function($) {
[135] Fix | Delete
[136] Fix | Delete
var data = {
[137] Fix | Delete
'action': 'wdev_logger_action',
[138] Fix | Delete
'log_action': 'delete',
[139] Fix | Delete
'log_module': 'foo',
[140] Fix | Delete
<?php echo WDEV_Logger::NONCE_NAME;?>: '<?php echo wp_create_nonce('action_[your_option_key]');?>'
[141] Fix | Delete
};
[142] Fix | Delete
jQuery.post(ajaxurl, data, function(response) {
[143] Fix | Delete
console.log(response);
[144] Fix | Delete
});
[145] Fix | Delete
});
[146] Fix | Delete
</script> <?php
[147] Fix | Delete
}
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Cleanup.
[152] Fix | Delete
*/
[153] Fix | Delete
$logger->cleanup();
[154] Fix | Delete
[155] Fix | Delete
// End.
[156] Fix | Delete
```
[157] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function