if opt.log_file is not None and not purge_log(opt.log_file, opt.log_age): parser.error("Error purging log file.") # Warn user about script threshold checking. if opt.script_threshold: print(SCRIPT_THRESHOLD_WARNING) # Setup log file try: logging.basicConfig(filename=opt.log_file, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s', datefmt=_DATE_FORMAT) except IOError: _, e, _ = sys.exc_info() parser.error("Error opening log file: %s" % str(e.args[1])) # Log MySQL Utilities version string if opt.log_file: logging.info(MSG_UTILITIES_VERSION.format(utility=program, version=VERSION_STRING)) try: rpl_cmds = RplCommands(master_val, slaves_val, options) rpl_cmds.execute_command(command, options) except UtilError: _, e, _ = sys.exc_info() print("ERROR: {0}".format(e.errmsg)) sys.exit(1) sys.exit(0)
'demote' : opt.demote, 'quiet' : opt.quiet, 'logging' : opt.log_file is not None, 'log_file' : opt.log_file, 'no_health' : opt.no_health, } # If command = HEALTH, turn on --force if command == 'health' or command == 'gtid': options['force'] = True # Purge log file of old data if opt.log_file is not None and not purge_log(opt.log_file, opt.log_age): parser.error("Error purging log file.") # Setup log file logging.basicConfig(filename=opt.log_file, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s', datefmt=_DATE_FORMAT) try: rpl_cmds = RplCommands(master_val, slaves_val, options) rpl_cmds.execute_command(command) except UtilError, e: print "ERROR:", e.errmsg exit(1) exit(0)
# Warn user about script threshold checking. if opt.script_threshold: print(SCRIPT_THRESHOLD_WARNING) # Setup log file try: logging.basicConfig(filename=opt.log_file, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s', datefmt=_DATE_FORMAT) except IOError: _, e, _ = sys.exc_info() parser.error("Error opening log file: %s" % str(e.args[1])) # Log MySQL Utilities version string if opt.log_file: logging.info( MSG_UTILITIES_VERSION.format(utility=program, version=VERSION_STRING)) try: rpl_cmds = RplCommands(master_val, slaves_val, options) rpl_cmds.execute_command(command, options) except UtilError: _, e, _ = sys.exc_info() print("ERROR: {0}".format(e.errmsg)) sys.exit(1) sys.exit(0)