summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2019-08-25 23:03:28 +0200
committermathieui <mathieui@mathieui.net>2019-08-25 23:05:06 +0200
commit0556b3d7a31cfeebe56875ba8a7c0f0a20ad810e (patch)
treec206a40e7072c75b9d3b3a6b3f1154bc076e235d
parent45d12b90928fb80dcdba8d4328e254827cb6cc80 (diff)
downloadpoezio-0556b3d7a31cfeebe56875ba8a7c0f0a20ad810e.tar.gz
poezio-0556b3d7a31cfeebe56875ba8a7c0f0a20ad810e.tar.bz2
poezio-0556b3d7a31cfeebe56875ba8a7c0f0a20ad810e.tar.xz
poezio-0556b3d7a31cfeebe56875ba8a7c0f0a20ad810e.zip
Remove code for loading logs
we MAM now
-rw-r--r--doc/source/configuration.rst18
-rw-r--r--poezio/config.py1
-rw-r--r--poezio/logger.py46
-rw-r--r--poezio/tabs/basetabs.py11
-rw-r--r--poezio/tabs/privatetab.py4
5 files changed, 0 insertions, 80 deletions
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index e394ee03..9619022a 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -892,14 +892,6 @@ Options related to logging.
.. glossary::
:sorted:
- load_log
-
- **Default value:** ``10``
-
- The number of line to preload in a chat buffer when it opens. The lines are
- loaded from the log files.
- ``0`` or a negative value here disable that option.
-
log_dir
**Default value:** ``[empty]``
@@ -1177,16 +1169,6 @@ found.
Ignore private messages sent from this room.
- load_log
-
- **Default value:** ``10``
-
- The number of line to preload in a chat buffer when it opens. The lines are
- loaded from the log files.
- ``0`` or a negative value here disable that option.
-
- No value makes poezio fall back to the global value.
-
password
**Default value:** ``[empty]``
diff --git a/poezio/config.py b/poezio/config.py
index cac2e858..f2160a86 100644
--- a/poezio/config.py
+++ b/poezio/config.py
@@ -90,7 +90,6 @@ DEFAULT_CONFIG = {
'keyfile': '',
'lang': 'en',
'lazy_resize': True,
- 'load_log': 10,
'log_dir': '',
'log_errors': True,
'max_lines_in_memory': 2048,
diff --git a/poezio/logger.py b/poezio/logger.py
index ca1f059f..da68a3a4 100644
--- a/poezio/logger.py
+++ b/poezio/logger.py
@@ -132,52 +132,6 @@ class Logger:
'Unable to open the log file (%s)', filename, exc_info=True)
return None
- def get_logs(self, jid: str,
- nb: int = 10) -> Optional[List[Dict[str, Any]]]:
- """
- Get the nb last messages from the log history for the given jid.
- Note that a message may be more than one line in these files, so
- this function is a little bit more complicated than “read the last
- nb lines”.
- """
- if config.get_by_tabname('load_log', jid) <= 0:
- return None
-
- if not config.get_by_tabname('use_log', jid):
- return None
-
- if nb <= 0:
- return None
-
- self._check_and_create_log_dir(jid, open_fd=False)
-
- filename = log_dir / jid
- try:
- fd = filename.open('rb')
- except FileNotFoundError:
- log.info('Non-existing log file (%s)', filename, exc_info=True)
- return None
- except OSError:
- log.error(
- 'Unable to open the log file (%s)', filename, exc_info=True)
- return None
- if not fd:
- return None
-
- # read the needed data from the file, we just search nb messages by
- # searching "\nM" nb times from the end of the file. We use mmap to
- # do that efficiently, instead of seek()s and read()s which are costly.
- with fd:
- try:
- lines = _get_lines_from_fd(fd, nb=nb)
- except Exception: # file probably empty
- log.error(
- 'Unable to mmap the log file for (%s)',
- filename,
- exc_info=True)
- return None
- return parse_log_lines(lines, jid)
-
def log_message(self,
jid: str,
nick: str,
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index e7a49073..f2da8469 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -519,14 +519,6 @@ class ChatTab(Tab):
self.update_commands()
self.update_keys()
- # Get the logs
- log_nb = config.get('load_log')
- logs = self.load_logs(log_nb)
-
- if logs:
- for message in logs:
- self._text_buffer.add_message(**message)
-
@property
def name(self) -> str:
if self._name is not None:
@@ -562,9 +554,6 @@ class ChatTab(Tab):
def general_jid(self) -> JID:
raise NotImplementedError
- def load_logs(self, log_nb: int) -> Optional[List[Dict[str, Any]]]:
- return logger.get_logs(self.jid.bare, log_nb)
-
def log_message(self,
txt: str,
nickname: str,
diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py
index 6229cd1c..f01476fa 100644
--- a/poezio/tabs/privatetab.py
+++ b/poezio/tabs/privatetab.py
@@ -104,10 +104,6 @@ class PrivateTab(OneToOneTab):
def remove_information_element(plugin_name):
del PrivateTab.additional_information[plugin_name]
- def load_logs(self, log_nb):
- logs = logger.get_logs(self.jid.full.replace('/', '\\'), log_nb)
- return logs
-
def log_message(self, txt, nickname, time=None, typ=1):
"""
Log the messages in the archives.