2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

01_FHEMWEB.pm: add optional FHEM log Monitor (Forum #45966)

git-svn-id: https://svn.fhem.de/fhem/trunk@10219 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-12-21 10:33:45 +00:00
parent 8d44282e09
commit f3956d61b1
4 changed files with 59 additions and 11 deletions

View File

@ -1,11 +1,15 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- feature: 50_Telegrambot: multiple contacts for send etc/removed depreacted messageTo,sendImageTo,sendPhotoTo/allowunknowncontacts - feature: FHEMWEB/Event Monitor: optional FHEM Log monitor.
- feature: 50_Telegrambot: multiple contacts for send etc/removed depreacted
messageTo,sendImageTo,sendPhotoTo/allowunknowncontacts
- bugfix: 70_PushNotifier: remove messages fron FHEM-logfile - bugfix: 70_PushNotifier: remove messages fron FHEM-logfile
- feature: 49_SSCam: function "snap" for taking snapshots added, - feature: 49_SSCam: function "snap" for taking snapshots added,
- bugfix: 49_SSCam: fixed a bug that functions may impact each other - bugfix: 49_SSCam: fixed a bug that functions may impact each other
- feature: 31_MilightDevice: Add restoreAtStart attribute so group devices (slot 'A') do not restore state by default at startup - feature: 31_MilightDevice: Add restoreAtStart attribute so group devices
- bugfix: 30_MilightBridge/31_MilightDevice: Fix startup restore. Fix crash on invalid hostname. (slot 'A') do not restore state by default at startup
- bugfix: 30_MilightBridge/31_MilightDevice: Fix startup restore. Fix crash
on invalid hostname.
- feature: YAMAHA_NP: Direct FM frequency setting. - feature: YAMAHA_NP: Direct FM frequency setting.
- feature: 30_pilight_xyz: possibility to change IO-Device (IODEV) - feature: 30_pilight_xyz: possibility to change IO-Device (IODEV)
- bugfix: YAMAHA_AVR: fixing not correctly volume smoothing - bugfix: YAMAHA_AVR: fixing not correctly volume smoothing

View File

@ -258,7 +258,10 @@ FW_Undef($$)
{ {
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
my $ret = TcpServer_Close($hash); my $ret = TcpServer_Close($hash);
%FW_visibleDeviceHash = FW_visibleDevices() if($hash->{inform}); if($hash->{inform}) {
%FW_visibleDeviceHash = FW_visibleDevices();
delete($logInform{$hash->{NAME}});
}
return $ret; return $ret;
} }
@ -527,6 +530,7 @@ FW_closeConn($)
delete($defs{$hash->{NAME}}); delete($defs{$hash->{NAME}});
} }
} }
POSIX::exit(0) if($hash->{isChild}); POSIX::exit(0) if($hash->{isChild});
FW_Read($hash, 1) if($hash->{BUF}); FW_Read($hash, 1) if($hash->{BUF});
} }
@ -685,6 +689,11 @@ FW_answerCall($)
delete $defs{$FW_wname}{asyncOutput}{$FW_id}; delete $defs{$FW_wname}{asyncOutput}{$FW_id};
} }
} }
if($me->{inform}{withLog}) {
$logInform{$me->{NAME}} = "FW_logInform";
} else {
delete($logInform{$me->{NAME}});
}
return -1; return -1;
} }
@ -1994,7 +2003,9 @@ FW_style($$)
FW_pO "<div id=\"content\">"; FW_pO "<div id=\"content\">";
my $filter = ($a[2] && $a[2] ne "1") ? $a[2] : ".*"; my $filter = ($a[2] && $a[2] ne "1") ? $a[2] : ".*";
FW_pO "Events (Filter: <a href=\"#\" id=\"eventFilter\">$filter</a>) ". FW_pO "Events (Filter: <a href=\"#\" id=\"eventFilter\">$filter</a>) ".
" <a href=\"#\" id=\"eventReset\">[Reset]</a>:<br>\n"; "&nbsp;&nbsp;<span class='changed'>FHEM log ".
"<input id='eventWithLog' type='checkbox'></span>".
"&nbsp;&nbsp;<button id='eventReset'>Reset</button><br><br>\n";
FW_pO "<div id=\"console\"></div>"; FW_pO "<div id=\"console\"></div>";
FW_pO "</div>"; FW_pO "</div>";
@ -2449,6 +2460,23 @@ FW_roomStatesForInform($$)
return $data; return $data;
} }
sub
FW_logInform($$)
{
my ($me, $msg) = @_; # _NO_ Log3 here!
my $ntfy = $defs{$me};
if(!$ntfy) {
delete $logInform{$me};
return;
}
if(!addToWritebuffer($ntfy, "<div class='changed'>$msg</div>") ){
TcpServer_Close($ntfy);
delete $logInform{$me};
delete $defs{$me};
}
}
sub sub
FW_Notify($$) FW_Notify($$)
{ {

View File

@ -212,6 +212,7 @@ use vars qw(%data); # Hash for user data
use vars qw(%defaultattr); # Default attributes, used by FHEM2FHEM use vars qw(%defaultattr); # Default attributes, used by FHEM2FHEM
use vars qw(%defs); # FHEM device/button definitions use vars qw(%defs); # FHEM device/button definitions
use vars qw(%inform); # Used by telnet_ActivateInform use vars qw(%inform); # Used by telnet_ActivateInform
use vars qw(%logInform); # Used by FHEMWEB/Event-Monitor
use vars qw(%intAt); # Internal at timer hash, global for benchmark use vars qw(%intAt); # Internal at timer hash, global for benchmark
use vars qw(%modules); # List of loaded modules (device/log/etc) use vars qw(%modules); # List of loaded modules (device/log/etc)
use vars qw(%ntfyHash); # hash of devices needed to be notified. use vars qw(%ntfyHash); # hash of devices needed to be notified.
@ -833,6 +834,13 @@ Log3($$$)
} else { } else {
print "$tim $loglevel: $text\n"; print "$tim $loglevel: $text\n";
} }
no strict "refs";
foreach my $li (keys %logInform) {
&{$logInform{$li}}($li, "$tim $loglevel : $text");
}
use strict "refs";
return undef; return undef;
} }

View File

@ -2,6 +2,7 @@ var consConn;
var consFilter, oldFilter; var consFilter, oldFilter;
var consLastIndex = 0; var consLastIndex = 0;
var withLog = 0;
log("Console is opening"); log("Console is opening");
function function
@ -24,8 +25,10 @@ consUpdate()
consLastIndex = len; consLastIndex = len;
log("Console Rcvd: "+new_content); log("Console Rcvd: "+new_content);
if(new_content.indexOf('<') != 0)
new_content = new_content.replace(/ /g, "&nbsp;");
$("#console") $("#console")
.append(new_content.replace(/ /g, "&nbsp;")) .append(new_content)
.scrollTop($("#console")[0].scrollHeight); .scrollTop($("#console")[0].scrollHeight);
} }
@ -40,7 +43,7 @@ consFill()
} }
consConn = new XMLHttpRequest(); consConn = new XMLHttpRequest();
var query = document.location.pathname+"?XHR=1"+ var query = document.location.pathname+"?XHR=1"+
"&inform=type=raw;filter="+consFilter+ "&inform=type=raw;withLog="+withLog+";filter="+consFilter+
"&timestamp="+new Date().getTime(); "&timestamp="+new Date().getTime();
query = addcsrf(query); query = addcsrf(query);
consConn.open("GET", query, true); consConn.open("GET", query, true);
@ -62,14 +65,14 @@ consStart()
if(consFilter == undefined) if(consFilter == undefined)
consFilter = ".*"; consFilter = ".*";
oldFilter = consFilter; oldFilter = consFilter;
setTimeout("consFill()", 1000); setTimeout(consFill, 1000);
$("a#eventReset").click(function(evt){ // Event Monitor Reset $("#eventReset").click(function(evt){ // Event Monitor Reset
log("Console resetted by user"); log("Console resetted by user");
$("#console").html(""); $("#console").html("");
}); });
$("a#eventFilter").click(function(evt){ // Event-Filter Dialog $("#eventFilter").click(function(evt){ // Event-Filter Dialog
$('body').append( $('body').append(
'<div id="evtfilterdlg">'+ '<div id="evtfilterdlg">'+
'<div>Filter:</div><br>'+ '<div>Filter:</div><br>'+
@ -96,6 +99,11 @@ consStart()
}}] }}]
}); });
}); });
$("#eventWithLog").change(function(evt){ // Event-Filter Dialog
withLog = ($("#eventWithLog").is(':checked') ? 1 : 0);
consFill();
});
} }
window.onload = consStart; window.onload = consStart;