mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-06-13 10:07:51 -04:00
- Create log_plugin_message() to prevent plugin logs from spamming the core logs - Create ability to log to different logs or a base log if parameter is not specified. - Update README.md - Change BasePlugin::log() wrapper function to log to log_plugin_message() and add logTo() to log to a specific plugin log. - Add plugin logger service to keep the logger loaded. Signed-off-by: objec <objecttothis@gmail.com>
27 lines
702 B
PHP
27 lines
702 B
PHP
<?php
|
|
|
|
use CodeIgniter\Events\Events;
|
|
|
|
if (!function_exists('log_plugin_message')) {
|
|
function log_plugin_message(string $pluginId, string $level, string $message, ?string $logName = null): void
|
|
{
|
|
service('pluginLogger')->log($pluginId, $level, $message, $logName);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('pluginContent')) {
|
|
function pluginContent(string $section, array $data = []): string
|
|
{
|
|
ob_start();
|
|
Events::trigger("view:{$section}", $data);
|
|
return ob_get_clean() ?: '';
|
|
}
|
|
}
|
|
|
|
if (!function_exists('pluginContentExists')) {
|
|
function pluginContentExists(string $section): bool
|
|
{
|
|
return !empty(Events::listeners("view:{$section}"));
|
|
}
|
|
}
|