Пример #1
0
 def write(self, msg):
     for logger in self.__loggers:
         # you want to be sure that a bug in one logger doesn't prevent
         # logging to all the other loggers
         try:
             logger.write(msg)
         except:
             _logexc(logger, msg)
Пример #2
0
 def write(self, msg):
     if isinstance(msg, StringType):
         msg = unicode(msg, self.__encoding, 'replace')
     f = self.__get_f()
     try:
         f.write(msg)
     except IOError, msg:
         _logexc(self, msg)
Пример #3
0
 def write(self, msg):
     for logger in self.__loggers:
         # you want to be sure that a bug in one logger doesn't prevent
         # logging to all the other loggers
         try:
             logger.write(msg)
         except:
             _logexc(logger, msg)
Пример #4
0
 def write(self, msg):
     if not isinstance(msg, str):
         msg.decode(self.__encoding, 'replace')
     f = self.__get_f()
     try:
         f.write(msg)
     except IOError as msg:
         _logexc(self, msg)
Пример #5
0
 def write(self, msg):
     if isinstance(msg, StringType):
         msg = unicode(msg, self.__encoding, 'replace')
     f = self.__get_f()
     try:
         f.write(msg)
     except IOError, msg:
         _logexc(self, msg)
Пример #6
0
 def close(self):
     for logger in self.__loggers:
         # you want to be sure that a bug in one logger doesn't prevent
         # logging to all the other loggers
         try:
             if logger <> sys.__stderr__ and logger <> sys.__stdout__:
                 logger.close()
         except:
             _logexc(logger)
Пример #7
0
 def flush(self):
     for logger in self.__loggers:
         if hasattr(logger, 'flush'):
             # you want to be sure that a bug in one logger doesn't prevent
             # logging to all the other loggers
             try:
                 logger.flush()
             except:
                 _logexc(logger)
Пример #8
0
 def close(self):
     for logger in self.__loggers:
         # you want to be sure that a bug in one logger doesn't prevent
         # logging to all the other loggers
         try:
             if logger <> sys.__stderr__ and logger <> sys.__stdout__:
                 logger.close()
         except:
             _logexc(logger)
Пример #9
0
 def flush(self):
     for logger in self.__loggers:
         if hasattr(logger, 'flush'):
             # you want to be sure that a bug in one logger doesn't prevent
             # logging to all the other loggers
             try:
                 logger.flush()
             except:
                 _logexc(logger)
Пример #10
0
    def __get_f(self):
	if self.__fp:
	    return self.__fp
	else:
	    try:
		ou = os.umask(002)
		try:
		    f = self.__fp = open(self.__filename, 'a+', 1)
		finally:
		    os.umask(ou)
	    except IOError, e:
                if self.__nofail:
                    _logexc(self, e)
                    f = self.__fp = sys.__stderr__
                else:
                    raise
            return f
Пример #11
0
 def __get_f(self):
     if self.__fp:
         return self.__fp
     else:
         try:
             ou = os.umask(007)
             try:
                 try:
                     f = codecs.open(self.__filename, "a+", self.__encoding, "replace", 1)
                 except LookupError:
                     f = open(self.__filename, "a+", 1)
                 self.__fp = f
             finally:
                 os.umask(ou)
         except IOError, e:
             if self.__nofail:
                 _logexc(self, e)
                 f = self.__fp = sys.__stderr__
             else:
                 raise
         return f
Пример #12
0
 def __get_f(self):
     if self.__fp:
         return self.__fp
     else:
         try:
             ou = os.umask(0o07)
             try:
                 try:
                     f = codecs.open(self.__filename, 'a+', self.__encoding,
                                     'replace', 1)
                 except LookupError:
                     f = open(self.__filename, 'a+', 1)
                 self.__fp = f
             finally:
                 os.umask(ou)
         except IOError as e:
             if self.__nofail:
                 _logexc(self, e)
                 f = self.__fp = sys.__stderr__
             else:
                 raise
         return f
Пример #13
0
    def write(self, msg):
	f = self.__get_f()
	try:
	    f.write(msg)
	except IOError, msg:
            _logexc(self, msg)