2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

93_Log2Syslog: prevent module from deactivation in case of unavailable Meta.pm

git-svn-id: https://svn.fhem.de/fhem/trunk@19029 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2019-03-25 20:01:23 +00:00
parent 86f15fac3e
commit 22ed6a08b5

View File

@ -37,9 +37,11 @@ use Scalar::Util qw(looks_like_number);
use Encode qw(encode_utf8);
eval "use IO::Socket::INET;1" or my $MissModulSocket = "IO::Socket::INET";
eval "use Net::Domain qw(hostname hostfqdn hostdomain domainname);1" or my $MissModulNDom = "Net::Domain";
eval "use FHEM::Meta;1" or my $modMetaAbsent = 1;
# Versions History intern:
our %Log2Syslog_vNotesIntern = (
"5.6.1" => "24.03.2019 prevent module from deactivation in case of unavailable Meta.pm ",
"5.6.0" => "23.03.2019 attribute exclErrCond to exclude events from rating as \"error\" ",
"5.5.0" => "18.03.2019 prepare for Meta.pm ",
"5.4.0" => "17.03.2019 new feature parseProfile = Automatic ",
@ -271,7 +273,7 @@ sub Log2Syslog_Initialize($) {
$readingFnAttributes
;
FHEM::Meta::InitMod( __FILE__, $hash ); # für Meta.pm (https://forum.fhem.de/index.php/topic,97589.0.html)
eval { FHEM::Meta::InitMod( __FILE__, $hash ) }; # für Meta.pm (https://forum.fhem.de/index.php/topic,97589.0.html)
return;
}
@ -321,17 +323,18 @@ sub Log2Syslog_Define($@) {
# nur Events dieser Devices an NotifyFn weiterleiten, NOTIFYDEV wird gesetzt wenn möglich
notifyRegexpChanged($hash, $hash->{HELPER}{EVNTLOG}) if($hash->{HELPER}{EVNTLOG});
$hash->{PEERHOST} = $a[2]; # Destination Host (Syslog Server)
$hash->{PEERHOST} = $a[2]; # Destination Host (Syslog Server)
}
$hash->{SEQNO} = 1; # PROCID in IETF, wird kontinuierlich hochgezählt
$hash->{SEQNO} = 1; # PROCID in IETF, wird kontinuierlich hochgezählt
$logInform{$hash->{NAME}} = "Log2Syslog_fhemlog"; # Funktion die in hash %loginform für $name eingetragen wird
$hash->{HELPER}{SSLVER} = "n.a."; # Initialisierung
$hash->{HELPER}{SSLALGO} = "n.a."; # Initialisierung
$hash->{HELPER}{LTIME} = time(); # Init Timestmp f. Ratenbestimmung
$hash->{HELPER}{OLDSEQNO} = $hash->{SEQNO}; # Init Sequenznummer f. Ratenbestimmung
$hash->{HELPER}{OLDSTATE} = "initialized";
$logInform{$hash->{NAME}} = "Log2Syslog_fhemlog"; # Funktion die in hash %loginform für $name eingetragen wird
$hash->{HELPER}{SSLVER} = "n.a."; # Initialisierung
$hash->{HELPER}{SSLALGO} = "n.a."; # Initialisierung
$hash->{HELPER}{LTIME} = time(); # Init Timestmp f. Ratenbestimmung
$hash->{HELPER}{OLDSEQNO} = $hash->{SEQNO}; # Init Sequenznummer f. Ratenbestimmung
$hash->{HELPER}{OLDSTATE} = "initialized";
$hash->{HELPER}{MODMETAABSENT} = 1 if($modMetaAbsent); # Modul Meta.pm nicht vorhanden
# Versionsinformationen setzen
Log2Syslog_setVersionInfo($hash);
@ -343,7 +346,7 @@ sub Log2Syslog_Define($@) {
readingsBulkUpdate($hash, "state", "initialized") if($hash->{MODEL}=~/Sender/);
readingsEndUpdate($hash,1);
Log2Syslog_trate($hash); # regelm. Berechnung Transfer Rate starten
Log2Syslog_trate($hash); # regelm. Berechnung Transfer Rate starten
return undef;
}
@ -2047,7 +2050,7 @@ sub Log2Syslog_setVersionInfo($) {
$hash->{HELPER}{PACKAGE} = __PACKAGE__;
$hash->{HELPER}{VERSION} = $v;
if($modules{$type}{META}{x_prereqs_src}) {
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) {
# META-Daten sind vorhanden
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SMAPortal}{META}}
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
@ -2056,7 +2059,7 @@ sub Log2Syslog_setVersionInfo($) {
$modules{$type}{META}{x_version} = $v;
}
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
if( __PACKAGE__ eq $type) {
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
use version 0.77; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
@ -3565,7 +3568,8 @@ $CONT = (split(">",$CONT))[1] if($CONT =~ /^<.*>.*$/);
"Net::Domain": 0
},
"recommends": {
"IO::Socket::SSL": 0
"IO::Socket::SSL": 0,
"FHEM::Meta": 0
},
"suggests": {
}