Package libxyz :: Package core :: Package logger :: Module logentry |
[hide private]
[frames] | no frames]

# Source Code for Module libxyz.core.logger.logentry

     1  #-*- coding: utf8 -*
     2  #
     3  # Max E. Kuznecov ~syhpoon <syhpoon@syhpoon.name> 2008
     4  #
     5  # This file is part of XYZCommander.
     6  # XYZCommander is free software: you can redistribute it and/or modify
     7  # it under the terms of the GNU Lesser Public License as published by
     8  # the Free Software Foundation, either version 3 of the License, or
     9  # (at your option) any later version.
    10  # XYZCommander is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  # GNU Lesser Public License for more details.
    14  # You should have received a copy of the GNU Lesser Public License
    15  # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>.
    16
    17  import time
    18
    19  import libxyz.ui as uilib
    20  from libxyz.ui import lowui
    21
    22 -class LogEntry(uilib.ListEntry):
    23      """
    24      Log message entry
    25      """
    26
    27 -    def __init__(self, msg, level, selected_attr, entry_attr=None,
    28                   write_time=True):
    29          """
    30          @param msg: Message
    31          @param level: Log level
    32          @param selected_attr: Atrribute of selected entry
    33          @param entry_attr: Entry text attribute
    34          @param write_time: Whether to write timestamp in entry
    35          """
    36
    37          super(LogEntry, self).__init__(msg, selected_attr, entry_attr)
    38
    39          self.level = level
    40
    41          if write_time:
    42              _time_clause = u"[%s]: " % time.strftime(r"%F %H:%M")
    43          else:
    44              _time_clause = ""
    45
    46          self._text = u"%(_time_clause)s(%(level)s) %(msg)s" % locals()
    47          self._sel_attr = selected_attr
    48          self._entry_attr = entry_attr
    49          self._content = lowui.Text(self._text)
    50