Files
opensourcepos/app/Helpers/plugin_helper.php
objec 7dde48c0ed Plugin logger
- 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>
2026-06-12 00:57:35 +04:00

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}"));
}
}