This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/contrib/log_net/main.php
2012-03-08 03:42:48 +00:00

22 lines
604 B
PHP

<?php
/*
* Name: Logging (Network)
* Author: Shish <webmaster@shishnet.org>
* Link: http://code.shishnet.org/shimmie2/
* Description: Send log events to a network port.
* Visibility: admin
*/
class LogNet extends Extension {
public function onLog(LogEvent $event) {
global $user;
if($event->priority > 10) {
// TODO: colour based on event->priority
$username = ($user && $user->name) ? $user->name : "Anonymous";
$str = sprintf("%-15s %-10s: %s", $_SERVER['REMOTE_ADDR'], $username, $event->message);
system("echo ".escapeshellarg($str)." | nc -q 0 localhost 5000");
}
}
}
?>