• Ondřej Lysoněk's avatar
    Support sending logs over DBus · 829c7de3
    Ondřej Lysoněk authored
    Add two DBus calls:
    log_capture_start(log_level, timeout)
     * This will instruct Tuned to create a new log handler, which will
       start writing log messages with level 'log_level' and higher to
       a buffer. The log levels are standard Python log levels (e.g.
       logging.INFO) or Tuned's custom log level LOG_LEVEL_CONSOLE which
       is defined as 60. The handler will be destroyed after 'timeout' seconds
       if contents of the buffer are not collected using log_capture_finish()
       before the timeout. If 'timeout' <= 0, log messages will be collected
       for as long as it takes before log_capture_finish() is called (use
       with care, so that you don't fill up memory with Tuned logs). This
       call returns a string ID of the log handler, a token, which should
       be passed to log_capture_finish().
     * This will return (as a string) log messages collected by a log handler
       associated with the 'token'. It will also destroy the log handler.
    These calls are privileged. They can only be called by the root user or
    by a user logged in on a local console (just like the change-profile DBus
    calls). This restriction is meant to prevent ordinary users from forcing
    Tuned to allocate an insane amount of memory for the log buffers and crash
    it (or other processes). In the future we may wish to replace this
    restriction with a configurable policy which determines how many (and how
    big) log buffers can a user with a given UID create. We may also want to
    destroy the log handler when the original caller disconnects from DBus.
    Signed-off-by: 's avatarOndřej Lysoněk <olysonek@redhat.com>