Remove code for loading logs
we MAM now
This commit is contained in:
parent
45d12b9092
commit
0556b3d7a3
5 changed files with 0 additions and 80 deletions
|
@ -892,14 +892,6 @@ Options related to logging.
|
||||||
.. glossary::
|
.. glossary::
|
||||||
:sorted:
|
: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
|
log_dir
|
||||||
|
|
||||||
**Default value:** ``[empty]``
|
**Default value:** ``[empty]``
|
||||||
|
@ -1177,16 +1169,6 @@ found.
|
||||||
|
|
||||||
Ignore private messages sent from this room.
|
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
|
password
|
||||||
|
|
||||||
**Default value:** ``[empty]``
|
**Default value:** ``[empty]``
|
||||||
|
|
|
@ -90,7 +90,6 @@ DEFAULT_CONFIG = {
|
||||||
'keyfile': '',
|
'keyfile': '',
|
||||||
'lang': 'en',
|
'lang': 'en',
|
||||||
'lazy_resize': True,
|
'lazy_resize': True,
|
||||||
'load_log': 10,
|
|
||||||
'log_dir': '',
|
'log_dir': '',
|
||||||
'log_errors': True,
|
'log_errors': True,
|
||||||
'max_lines_in_memory': 2048,
|
'max_lines_in_memory': 2048,
|
||||||
|
|
|
@ -132,52 +132,6 @@ class Logger:
|
||||||
'Unable to open the log file (%s)', filename, exc_info=True)
|
'Unable to open the log file (%s)', filename, exc_info=True)
|
||||||
return None
|
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,
|
def log_message(self,
|
||||||
jid: str,
|
jid: str,
|
||||||
nick: str,
|
nick: str,
|
||||||
|
|
|
@ -519,14 +519,6 @@ class ChatTab(Tab):
|
||||||
self.update_commands()
|
self.update_commands()
|
||||||
self.update_keys()
|
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
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
if self._name is not None:
|
if self._name is not None:
|
||||||
|
@ -562,9 +554,6 @@ class ChatTab(Tab):
|
||||||
def general_jid(self) -> JID:
|
def general_jid(self) -> JID:
|
||||||
raise NotImplementedError
|
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,
|
def log_message(self,
|
||||||
txt: str,
|
txt: str,
|
||||||
nickname: str,
|
nickname: str,
|
||||||
|
|
|
@ -104,10 +104,6 @@ class PrivateTab(OneToOneTab):
|
||||||
def remove_information_element(plugin_name):
|
def remove_information_element(plugin_name):
|
||||||
del PrivateTab.additional_information[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):
|
def log_message(self, txt, nickname, time=None, typ=1):
|
||||||
"""
|
"""
|
||||||
Log the messages in the archives.
|
Log the messages in the archives.
|
||||||
|
|
Loading…
Reference in a new issue