3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering This file is part of systemd.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering Copyright 2011 Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering (at your option) any later version.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering systemd is distributed in the hope that it will be useful, but
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering Lesser General Public License for more details.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog if (_unlikely_(cached_printk_time < 0)) {
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog read_one_line_file("/sys/module/printk/parameters/time", &p) >= 0
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek char tbuf[sizeof("[] ")-1 + DECIMAL_STR_MAX(ts.tv_sec) + DECIMAL_STR_MAX(ts.tv_nsec)-3 + 1];
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek char header_pid[sizeof("[]: ")-1 + DECIMAL_STR_MAX(pid_t)];
fb4729006a7174472e8a435b0887e532cd6217fcZbigniew Jędrzejewski-Szmek _cleanup_free_ char *ident_buf = NULL;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering if (LOG_PRI(priority) > s->max_level_console)
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog /* First: timestamp */
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek xsprintf(tbuf, "[%5"PRI_TIME".%06ld] ",
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog /* Second: identifier and PID */
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering get_process_comm(ucred->pid, &ident_buf);
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek xsprintf(header_pid, "["PID_FMT"]: ", ucred->pid);
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering IOVEC_SET_STRING(iovec[n++], identifier);
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering IOVEC_SET_STRING(iovec[n++], header_pid);
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering IOVEC_SET_STRING(iovec[n++], identifier);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog /* Fourth: message */
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering tty = s->tty_path ? s->tty_path : "/dev/console";
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
709f6e46a35ec492b70eb92943d82a8d838ce918Michal Schmidt log_debug_errno(fd, "Failed to open %s for logging: %m", tty);
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidt log_debug_errno(errno, "Failed to write to %s for logging: %m", tty);