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)
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)
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)
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)
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)
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
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
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
def write(self, msg): f = self.__get_f() try: f.write(msg) except IOError, msg: _logexc(self, msg)