'The shinken logging wrapper can write to a local file if needed
and return the file descriptor so we can avoid to
close it.
Add logging to a local log-file.
The file will be rotated once a day'

def register_local_log(self, path, level=None, purge_buffer=True):

    self.log_set = True
    if (os.path.exists(path) and (not stat.S_ISREG(os.stat(path).st_mode))):
        handler = FileHandler(path)
    else:
        handler = TimedRotatingFileHandler(path, 'midnight', backupCount=5)
    if (level is not None):
        handler.setLevel(level)
    if (self.name is not None):
        handler.setFormatter(defaultFormatter_named)
    else:
        handler.setFormatter(defaultFormatter)
    self.addHandler(handler)
    if purge_buffer:
        self._destack()
    return handler.stream.fileno()
