// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2023 Red Hat */ #include "logger.h" #include <asm/current.h> #include <linux/delay.h> #include <linux/hardirq.h> #include <linux/module.h> #include <linux/printk.h> #include <linux/sched.h> #include "errors.h" #include "thread-device.h" #include "thread-utils.h" int vdo_log_level = …; int vdo_get_log_level(void) { … } static const char *get_current_interrupt_type(void) { … } /** * emit_log_message_to_kernel() - Emit a log message to the kernel at the specified priority. * * @priority: The priority at which to log the message * @fmt: The format string of the message */ static void emit_log_message_to_kernel(int priority, const char *fmt, ...) { … } /** * emit_log_message() - Emit a log message to the kernel log in a format suited to the current * thread context. * * Context info formats: * * interrupt: uds[NMI]: blah * kvdo thread: kvdo12:foobarQ: blah * thread w/device id: kvdo12:myprog: blah * other thread: uds: myprog: blah * * Fields: module name, interrupt level, process name, device ID. * * @priority: the priority at which to log the message * @module: The name of the module doing the logging * @prefix: The prefix of the log message * @vaf1: The first message format descriptor * @vaf2: The second message format descriptor */ static void emit_log_message(int priority, const char *module, const char *prefix, const struct va_format *vaf1, const struct va_format *vaf2) { … } /* * vdo_log_embedded_message() - Log a message embedded within another message. * @priority: the priority at which to log the message * @module: the name of the module doing the logging * @prefix: optional string prefix to message, may be NULL * @fmt1: format of message first part (required) * @args1: arguments for message first part (required) * @fmt2: format of message second part */ void vdo_log_embedded_message(int priority, const char *module, const char *prefix, const char *fmt1, va_list args1, const char *fmt2, ...) { … } int vdo_vlog_strerror(int priority, int errnum, const char *module, const char *format, va_list args) { … } int __vdo_log_strerror(int priority, int errnum, const char *module, const char *format, ...) { … } void vdo_log_backtrace(int priority) { … } void __vdo_log_message(int priority, const char *module, const char *format, ...) { … } /* * Sleep or delay a few milliseconds in an attempt to allow the log buffers to be flushed lest they * be overrun. */ void vdo_pause_for_logger(void) { … }