FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 84b68f99 authored by L. Bower's avatar L. Bower
Browse files

removing unused function

parent 74db142d
No related branches found
No related tags found
No related merge requests found
......@@ -216,48 +216,48 @@ class Processor:
}
def move_default_logfile_handler(self, dstPathName, srcPathName = None, FileHandlerName = 'handler_file', ):
'''For on-the-fly move of logging from default file to another. Copies the
contents of the source log file to destination, switches file handler in
logger, then removes source log file.'''
if srcPathName is None:
srcPathName = self.log_path_default
self.logger.info(f"Moving logfile location from:\n{srcPathName}\nto:\n{dstPathName}")
# copy old log file to new filename
srcPath = Path(srcPathName)
dstPath = Path(dstPathName)
assert srcPath.exists()
assert dstPath.parent.is_dir()
oldFileHandler = [h for h in self.logger.handlers if h.name == FileHandlerName][0]
oldFormatter = oldFileHandler.formatter
# define new file handler
newfilehandler = logging.FileHandler(dstPath, mode = oldFileHandler.mode)
newfilehandler.setLevel(oldFileHandler.level)
newfilehandler.setFormatter(oldFormatter)
shutil.copyfile(srcPath, dstPath)
# add handler for destination file
self.logger.info('Adding new logging file handler to destination path')
self.logger.addHandler(newfilehandler)
# remove handler for source file
self.logger.info('Stopping write to old file handler')
self.logger.removeHandler(oldFileHandler)
oldFileHandler.close()
self.logger.info('Successfully stopped write to old file handler')
# delete old log file
self.logger.info('Deleting old log file, since all content available in new log file stream')
os.rename(srcPathName, srcPathName + 'removed')
return
# def move_default_logfile_handler(self, dstPathName, srcPathName = None, FileHandlerName = 'handler_file', ):
# '''For on-the-fly move of logging from default file to another. Copies the
# contents of the source log file to destination, switches file handler in
# logger, then removes source log file.'''
#
# if srcPathName is None:
# srcPathName = self.log_path_default
#
# self.logger.info(f"Moving logfile location from:\n{srcPathName}\nto:\n{dstPathName}")
#
# # copy old log file to new filename
# srcPath = Path(srcPathName)
# dstPath = Path(dstPathName)
# assert srcPath.exists()
# assert dstPath.parent.is_dir()
#
# oldFileHandler = [h for h in self.logger.handlers if h.name == FileHandlerName][0]
# oldFormatter = oldFileHandler.formatter
#
# # define new file handler
# newfilehandler = logging.FileHandler(dstPath, mode = oldFileHandler.mode)
# newfilehandler.setLevel(oldFileHandler.level)
# newfilehandler.setFormatter(oldFormatter)
#
# shutil.copyfile(srcPath, dstPath)
#
# # add handler for destination file
# self.logger.info('Adding new logging file handler to destination path')
#
# self.logger.addHandler(newfilehandler)
#
# # remove handler for source file
# self.logger.info('Stopping write to old file handler')
# self.logger.removeHandler(oldFileHandler)
# oldFileHandler.close()
# self.logger.info('Successfully stopped write to old file handler')
#
# # delete old log file
# self.logger.info('Deleting old log file, since all content available in new log file stream')
# os.rename(srcPathName, srcPathName + 'removed')
#
# return
def parse_and_check_args(self) -> dict:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment