From cc84d3c00dabfb3b4fc88aedf2144f6911caf7eb Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 27 Jan 2020 23:23:20 +0000 Subject: [PATCH] move logs to new data_directory(), log all channels by default --- modules/channel_log/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/channel_log/__init__.py b/modules/channel_log/__init__.py index cffa7271..51ad7c04 100644 --- a/modules/channel_log/__init__.py +++ b/modules/channel_log/__init__.py @@ -10,12 +10,11 @@ LOGS_DIRECTORY = os.path.join(ROOT_DIRECTORY, "logs") @utils.export("channelset", utils.BoolSetting("log", "Enable/disable channel logging")) class Module(ModuleManager.BaseModule): - def _log_file(self, server_name, channel_name): - return open(os.path.join(LOGS_DIRECTORY, - "%s%s.log" % (server_name, channel_name)), "a") + def _file(self, server_name, channel_name): + return self.data_directory("%s/%s.log" % (server_name, channel_name)) def _log(self, event, channel): - if channel.get_setting("log", False): - with self._log_file(str(event["server"]), str(channel)) as log: + if channel.get_setting("log", True): + with open(self._file(str(event["server"]), str(channel)), "a") as log: timestamp = datetime.datetime.now().strftime("%x %X") log.write("%s %s\n" % (timestamp, event["line"]))