64 lines
1.2 KiB
PHP
64 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace alveolata\log;
|
||
|
|
||
|
// require_once(DIR_ALVEOLATA . '/definitions.php');
|
||
|
require_once(DIR_ALVEOLATA . '/string/functions.php');
|
||
|
require_once(DIR_ALVEOLATA . '/report/functions.php');
|
||
|
require_once(DIR_ALVEOLATA . '/log/output-interface.php');
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
class implementation_libnotify implements interface_output
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* @param int $level_threshold
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function __construct(
|
||
|
)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @implementation
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function process(
|
||
|
int $level,
|
||
|
\alveolata\report\struct_report $report
|
||
|
) : void
|
||
|
{
|
||
|
$command = \alveolata\string\coin(
|
||
|
'notify-send \'[{{level}}] {{incident}}\' \'{{details}}\'',
|
||
|
[
|
||
|
'level' => output_translate_level($level),
|
||
|
'incident' => $report->incident,
|
||
|
'details' => implode(
|
||
|
"\n",
|
||
|
array_map(
|
||
|
function ($key) use (&$report) {
|
||
|
$value = $report->details[$key];
|
||
|
return \alveolata\string\coin(
|
||
|
'{{key}}: {{value}}',
|
||
|
[
|
||
|
'key' => $key,
|
||
|
'value' => json_encode($value),
|
||
|
]
|
||
|
);
|
||
|
},
|
||
|
array_keys($report->details)
|
||
|
)
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
exec($command);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|