network logging, for irccat
This commit is contained in:
parent
df72e4580b
commit
409a3b9b23
2 changed files with 22 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -37,6 +37,7 @@ ext/image_hash_ban
|
|||
ext/ipban
|
||||
ext/link_image
|
||||
ext/log_db
|
||||
ext/log_net
|
||||
ext/mass_tagger
|
||||
ext/news
|
||||
ext/notes
|
||||
|
|
21
contrib/log_net/main.php
Normal file
21
contrib/log_net/main.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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) {
|
||||
$username = ($user && $user->name) ? $user->name : "Anonymous";
|
||||
$str = sprintf("%2d %15s (%s): %s - %s", $event->priority, $_SERVER['REMOTE_ADDR'], $username, $event->section, $event->message);
|
||||
system("echo ".escapeshellarg($str)." | nc -q 0 localhost 5000");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in a new issue