From 301e86190e30c80748c9efc3db576e30589db6b1 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 14 Nov 2019 13:31:12 +0000 Subject: move default log location to ~/.bitbot/logs/ --- bitbotd | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bitbotd') diff --git a/bitbotd b/bitbotd index defd93c7..97ae8cb2 100755 --- a/bitbotd +++ b/bitbotd @@ -32,8 +32,7 @@ arg_parser.add_argument("--database", "-d", help="Location of the sqlite3 database file") arg_parser.add_argument("--log-dir", "-l", - help="Location of the log directory", - default=os.path.join(directory, "logs")) + help="Location of the log directory") arg_parser.add_argument("--add-server", "-a", help="Add a new server", action="store_true") @@ -60,25 +59,31 @@ if args.version: print("BitBot %s" % IRCBot.VERSION) sys.exit(0) +if not os.path.isdir(args.data_dir): + os.mkdir(args.data_dir) + database_location = None lock_location = None sock_locaiton = None +log_directory = None if not args.database == None: database_location = args.database lock_location = "%s.lock" % args.database sock_location = "%s.sock" % args.database else: - if not os.path.isdir(args.data_dir): - os.mkdir(args.data_dir) database_location = os.path.join(args.data_dir, "bot.db") lock_location = os.path.join(args.data_dir, "bot.lock") sock_location = os.path.join(args.data_dir, "bot.sock") +log_directory = args.log_dir or os.path.join(args.data_dir, "logs") +if not os.path.isdir(log_directory): + os.mkdir(log_directory) + log_level = args.log_level if not log_level: log_level = "debug" if args.verbose else "warn" -log = Logging.Log(not args.no_logging, log_level, args.log_dir) +log = Logging.Log(not args.no_logging, log_level, log_directory) log.info("Starting BitBot %s (Python v%s, db %s)", [IRCBot.VERSION, platform.python_version(), database_location]) -- cgit v1.3.1-10-gc9f91