diff options
| author | 2020-01-27 23:23:20 +0000 | |
|---|---|---|
| committer | 2020-01-27 23:25:04 +0000 | |
| commit | cc84d3c00dabfb3b4fc88aedf2144f6911caf7eb (patch) | |
| tree | 5b5679fdf24d1d805f98ea40c0a023faa830375f | |
| parent | add data_directory() func to BaseModule, to get path to data file (diff) | |
| signature | ||
move logs to new data_directory(), log all channels by default
| -rw-r--r-- | modules/channel_log/__init__.py | 9 |
1 files 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"])) |
