Commit 3a7aadbe authored by thomas.forbriger's avatar thomas.forbriger Committed by Checksum Backup @bromo

csbackgen, csbackntfy, csfile: avoid newline in log message

parent 6ee47119
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
# 26/10/2013 V0.8 dry-run flag introduced # 26/10/2013 V0.8 dry-run flag introduced
# 09/11/2013 V0.8.1 adjusted help text # 09/11/2013 V0.8.1 adjusted help text
# 01/08/2019 V0.8.2 (thof): provide additional debug output # 01/08/2019 V0.8.2 (thof): provide additional debug output
# 02/08/2019 V0.8.3 (thof): do not produce multiline log messages
# #
# ============================================================================= # =============================================================================
...@@ -54,7 +55,7 @@ import csbacklog ...@@ -54,7 +55,7 @@ import csbacklog
import pidlock import pidlock
import csbackErrorCodes as eCodes import csbackErrorCodes as eCodes
__version__ = "V0.8.1" __version__ = "V0.8.3"
__subversion__ = "$Id$" __subversion__ = "$Id$"
__license__ = "GPLv2+" __license__ = "GPLv2+"
__author__ = "Daniel Armbruster" __author__ = "Daniel Armbruster"
...@@ -295,7 +296,10 @@ def main(argv=None): ...@@ -295,7 +296,10 @@ def main(argv=None):
# generate checksumfiles for subdirectories (recursive mode) # generate checksumfiles for subdirectories (recursive mode)
# so collect all available subdirectories here (excluding subdirectories) # so collect all available subdirectories here (excluding subdirectories)
if not notRecursive: if not notRecursive:
logger.getLogger().debug("collect subdirectories\n srcpath: %s\n regexes: %s\n followlinks: %s" % (srcpath, regexes, followlinks)) logger.getLogger().debug("collect subdirectories")
logger.getLogger().debug(" srcpath: '%s'" % srcpath)
logger.getLogger().debug(" regexes: '%s'" % regexes)
logger.getLogger().debug(" followlinks: '%s'" % followlinks)
dirs.extend(csfile.getSubDirectories(srcpath, regexes, followlinks)) dirs.extend(csfile.getSubDirectories(srcpath, regexes, followlinks))
# if a target directory had been passed extend the list of # if a target directory had been passed extend the list of
# target directories replacing the trunk of the source directory with the # target directories replacing the trunk of the source directory with the
......
...@@ -276,8 +276,8 @@ def main(argv=None): ...@@ -276,8 +276,8 @@ def main(argv=None):
timeStamp=dt.datetime.strptime(str(now.year)+" "+" ".join(str(n) timeStamp=dt.datetime.strptime(str(now.year)+" "+" ".join(str(n)
for n in line.split()[0:3]),"%Y %b %d %H:%M:%S") for n in line.split()[0:3]),"%Y %b %d %H:%M:%S")
except: except:
raise Error(("Error while parsing log line\n %s\n" logger.getLogger().error("Error while parsing log line: '%s'" % line)
+" from file %s") % (line, path), raise Error("Error while parsing log line from file %s" % path,
eCodes.GLOBAL_UnhandledException) eCodes.GLOBAL_UnhandledException)
if 'CRITICAL' in line: if 'CRITICAL' in line:
if timeStamp > timeLimit: if timeStamp > timeLimit:
...@@ -291,10 +291,9 @@ def main(argv=None): ...@@ -291,10 +291,9 @@ def main(argv=None):
elif 'INFO' in line: elif 'INFO' in line:
infoDeque.appendleft("logfile: "+path+"\n"+line) infoDeque.appendleft("logfile: "+path+"\n"+line)
else: else:
logger.getLogger().info(("Illegal line in logfile found\n" logger.getLogger().info("Illegal line in logfile found")
+" Line does not contain any of the csback message level keywords\n" logger.getLogger().info(" Line does not contain any of the csback message level keywords")
+" %s %s %s %s\n The log line is:\n %s") logger.getLogger().info(" The log line is: '%s'" % line)
% ("CRITICAL", "ERROR", "WARNING", "INFO", line))
except IOError as err: except IOError as err:
raise Error("Error while reading logfiles: "+err.filename, \ raise Error("Error while reading logfiles: "+err.filename, \
eCodes.NTFY_IOError) eCodes.NTFY_IOError)
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
# message, if application of a regex fails # message, if application of a regex fails
# V0.6.7 (thof) capture problem with whitespace in file names # V0.6.7 (thof) capture problem with whitespace in file names
# which results in not accepted hash types # which results in not accepted hash types
# 02/08/2019 V0.6.8 (thof) do not write newline to log entries
# #
# ============================================================================= # =============================================================================
""" CsFile module to handle checksumfiles. """ """ CsFile module to handle checksumfiles. """
...@@ -72,7 +73,7 @@ from datetime import date ...@@ -72,7 +73,7 @@ from datetime import date
import csbacklog import csbacklog
import csbackErrorCodes as eCodes import csbackErrorCodes as eCodes
__version__ = "V0.6.7" __version__ = "V0.6.8"
__subversion__ = "$Id$" __subversion__ = "$Id$"
__license__ = "GPLv2+" __license__ = "GPLv2+"
__author__ = "Daniel Armbruster" __author__ = "Daniel Armbruster"
...@@ -500,11 +501,11 @@ class CsLine: ...@@ -500,11 +501,11 @@ class CsLine:
try: try:
hashfunc = hashlib.new(self.hashfunc) hashfunc = hashlib.new(self.hashfunc)
except: except:
raise CsFileError(("When evaluating checksum file entry\n in directory %s\n" self.logger.error("Start reading checksumfile '%s'",self.filename)
+" hash type '%s' as specified for file '%s' is not accepted\n" self.logger.error(" Checksum line: '%s'",self)
+" consider a problem with whitespace in file names\n" self.logger.error(" Hash is not accepted: '%s'",self.hasfunc)
+" the respective checksum file entry is\n" raise CsFileError("Abort caused by ill-formatted checksum line '%'"
+" %s") % (self.srcdir, self.hashfunc, self.filename, self), eCodes.GLOBAL_UnhandledException) % self, eCodes.GLOBAL_UnhandledException)
blockSize = chunkSize * hashfunc.block_size blockSize = chunkSize * hashfunc.block_size
path = os.path.join(self.srcdir, self.filename) path = os.path.join(self.srcdir, self.filename)
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment