'Write a new message : append it in the buffer,
display it to the screen (if needed), and write
it in the log file (if needed).
@param level: Message level.
@type level: C{int}
@param text: Message content.
@type text: C{str}
@param ctxt: The caller instance.'

def newMessage(self, level, text, ctxt=None):

    if (((level < self.LOG_ERROR) and config.quiet) or ((level <= self.LOG_INFO) and (not config.verbose))):
        return
    if config.debug:
        from hachoir_core.error import getBacktrace
        backtrace = getBacktrace(None)
        if backtrace:
            text += ('\n\n' + backtrace)
    _text = text
    if hasattr(ctxt, '_logger'):
        _ctxt = ctxt._logger()
        if (_ctxt is not None):
            text = ('[%s]    %s' % (_ctxt, text))
    if self.use_buffer:
        if (not self.__buffer.has_key(level)):
            self.__buffer[level] = [text]
        else:
            self.__buffer[level].append(text)
    prefix = self.level_name.get(level, '[info]')
    if self.use_print:
        sys.stdout.flush()
        sys.stderr.write(('%s    %s\n' % (prefix, text)))
        sys.stderr.flush()
    if self.__file:
        self._writeIntoFile(('%s    %s' % (prefix, text)))
    if self.on_new_message:
        self.on_new_message(level, prefix, _text, ctxt)
