void Log::kmsgLog()

in src/oomd/Log.cpp [98:118]


void Log::kmsgLog(const std::string& buf, const std::string& prefix) const {
  if (kmsg_fd_ >= 0) {
    std::string message(buf);
    if (prefix.size() > 0) {
      message.insert(0, prefix + ": ");
    }
    // Make sure message ends with newline or kernel won't show it immediately
    if (message.size() != 0 && message.back() != '\n') {
      message.push_back('\n');
    }
    auto ret = Util::writeFull(kmsg_fd_, message.data(), message.size());
    if (ret == -1) {
      perror("error writing");
      OLOG << "Unable to write log to output file";
    }
  } else {
    OLOG << "kmsg logging disabled b/c kmsg_fd_=" << kmsg_fd_;
  }

  OLOG << buf;
}