mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +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:
parent
8d44282e09
commit
f3956d61b1
10
fhem/CHANGED
10
fhem/CHANGED
@ -1,11 +1,15 @@
|
||||
# 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.
|
||||
- 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
|
||||
- feature: 49_SSCam: function "snap" for taking snapshots added,
|
||||
- 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
|
||||
- bugfix: 30_MilightBridge/31_MilightDevice: Fix startup restore. Fix crash on invalid hostname.
|
||||
- feature: 31_MilightDevice: Add restoreAtStart attribute so group devices
|
||||
(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: 30_pilight_xyz: possibility to change IO-Device (IODEV)
|
||||
- bugfix: YAMAHA_AVR: fixing not correctly volume smoothing
|
||||
|
@ -258,7 +258,10 @@ FW_Undef($$)
|
||||
{
|
||||
my ($hash, $arg) = @_;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -527,6 +530,7 @@ FW_closeConn($)
|
||||
delete($defs{$hash->{NAME}});
|
||||
}
|
||||
}
|
||||
|
||||
POSIX::exit(0) if($hash->{isChild});
|
||||
FW_Read($hash, 1) if($hash->{BUF});
|
||||
}
|
||||
@ -685,6 +689,11 @@ FW_answerCall($)
|
||||
delete $defs{$FW_wname}{asyncOutput}{$FW_id};
|
||||
}
|
||||
}
|
||||
if($me->{inform}{withLog}) {
|
||||
$logInform{$me->{NAME}} = "FW_logInform";
|
||||
} else {
|
||||
delete($logInform{$me->{NAME}});
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -1993,8 +2002,10 @@ FW_style($$)
|
||||
"</script>";
|
||||
FW_pO "<div id=\"content\">";
|
||||
my $filter = ($a[2] && $a[2] ne "1") ? $a[2] : ".*";
|
||||
FW_pO "Events (Filter:<a href=\"#\" id=\"eventFilter\">$filter</a>)".
|
||||
" <a href=\"#\" id=\"eventReset\">[Reset]</a>:<br>\n";
|
||||
FW_pO "Events (Filter: <a href=\"#\" id=\"eventFilter\">$filter</a>) ".
|
||||
" <span class='changed'>FHEM log ".
|
||||
"<input id='eventWithLog' type='checkbox'></span>".
|
||||
" <button id='eventReset'>Reset</button><br><br>\n";
|
||||
FW_pO "<div id=\"console\"></div>";
|
||||
FW_pO "</div>";
|
||||
|
||||
@ -2449,6 +2460,23 @@ FW_roomStatesForInform($$)
|
||||
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
|
||||
FW_Notify($$)
|
||||
{
|
||||
|
@ -212,6 +212,7 @@ use vars qw(%data); # Hash for user data
|
||||
use vars qw(%defaultattr); # Default attributes, used by FHEM2FHEM
|
||||
use vars qw(%defs); # FHEM device/button definitions
|
||||
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(%modules); # List of loaded modules (device/log/etc)
|
||||
use vars qw(%ntfyHash); # hash of devices needed to be notified.
|
||||
@ -833,6 +834,13 @@ Log3($$$)
|
||||
} else {
|
||||
print "$tim $loglevel: $text\n";
|
||||
}
|
||||
|
||||
no strict "refs";
|
||||
foreach my $li (keys %logInform) {
|
||||
&{$logInform{$li}}($li, "$tim $loglevel : $text");
|
||||
}
|
||||
use strict "refs";
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ var consConn;
|
||||
|
||||
var consFilter, oldFilter;
|
||||
var consLastIndex = 0;
|
||||
var withLog = 0;
|
||||
log("Console is opening");
|
||||
|
||||
function
|
||||
@ -24,8 +25,10 @@ consUpdate()
|
||||
consLastIndex = len;
|
||||
|
||||
log("Console Rcvd: "+new_content);
|
||||
if(new_content.indexOf('<') != 0)
|
||||
new_content = new_content.replace(/ /g, " ");
|
||||
$("#console")
|
||||
.append(new_content.replace(/ /g, " "))
|
||||
.append(new_content)
|
||||
.scrollTop($("#console")[0].scrollHeight);
|
||||
}
|
||||
|
||||
@ -40,7 +43,7 @@ consFill()
|
||||
}
|
||||
consConn = new XMLHttpRequest();
|
||||
var query = document.location.pathname+"?XHR=1"+
|
||||
"&inform=type=raw;filter="+consFilter+
|
||||
"&inform=type=raw;withLog="+withLog+";filter="+consFilter+
|
||||
"×tamp="+new Date().getTime();
|
||||
query = addcsrf(query);
|
||||
consConn.open("GET", query, true);
|
||||
@ -62,14 +65,14 @@ consStart()
|
||||
if(consFilter == undefined)
|
||||
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");
|
||||
$("#console").html("");
|
||||
});
|
||||
|
||||
$("a#eventFilter").click(function(evt){ // Event-Filter Dialog
|
||||
$("#eventFilter").click(function(evt){ // Event-Filter Dialog
|
||||
$('body').append(
|
||||
'<div id="evtfilterdlg">'+
|
||||
'<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;
|
||||
|
Loading…
Reference in New Issue
Block a user