Skip to content

Commit 41a8d83

Browse files
authored
Merge pull request #880 from terminaldweller/irssilogger
irssi_logger.pl update - the script now checks for DB disconnects and reconnects if disconnected
2 parents 4af9996 + fa55bda commit 41a8d83

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/irssi_logger.pl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# - postgresql
1212
# - postgresql-contrib (pg_trgm)
1313

14-
$VERSION = "1.1";
14+
$VERSION = "1.2";
1515
%IRSSI = (
1616
authors => "Aaron Bieber",
1717
contact => "deftly\@gmail.com",
@@ -118,7 +118,13 @@ sub write_db {
118118

119119
defined or $_ = "" for @vals;
120120

121-
$dbh->do($sql, undef, @vals) || Irssi::print("Can't log to DB! " . DBI::errstr);
121+
$dbh->do($sql, undef, @vals);
122+
if ($dbh->err) {
123+
Irssi::print("Can't log to DB! " . DBI::errstr);
124+
if (!$dbh->ping) {
125+
$dbh->connect();
126+
}
127+
}
122128
}
123129
}
124130

0 commit comments

Comments
 (0)