Skip to content
Snippets Groups Projects
Commit b4520300 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

log: Add a flag to enable log drivers


At present there is no way to disable a log driver. But the syslog driver
causes (attempted) network traffic in sandbox every time a log message
is printed, which is often.

Add a flag to enable a log driver. Adjust struct log_device to use a short
for next_filter_num so that no more memory is used for devices. Also fix
a missing line in the struct log_driver comment while here.

To maintain compatibility, enable it for all drivers for now.

Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
parent 26637e2e
No related branches found
No related tags found
No related merge requests found
......@@ -207,7 +207,8 @@ static int log_dispatch(struct log_rec *rec)
/* Emit message */
processing_msg = 1;
list_for_each_entry(ldev, &gd->log_head, sibling_node) {
if (log_passes_filters(ldev, rec))
if ((ldev->flags & LOGDF_ENABLE) &&
log_passes_filters(ldev, rec))
ldev->drv->emit(ldev, rec);
}
processing_msg = 0;
......@@ -329,6 +330,7 @@ int log_init(void)
}
INIT_LIST_HEAD(&ldev->filter_head);
ldev->drv = drv;
ldev->flags = drv->flags;
list_add_tail(&ldev->sibling_node,
(struct list_head *)&gd->log_head);
drv++;
......
......@@ -44,4 +44,5 @@ static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
LOG_DRIVER(console) = {
.name = "console",
.emit = log_console_emit,
.flags = LOGDF_ENABLE,
};
......@@ -107,4 +107,5 @@ out:
LOG_DRIVER(syslog) = {
.name = "syslog",
.emit = log_syslog_emit,
.flags = LOGDF_ENABLE,
};
......@@ -307,10 +307,16 @@ struct log_rec {
struct log_device;
enum log_device_flags {
LOGDF_ENABLE = BIT(0), /* Device is enabled */
};
/**
* struct log_driver - a driver which accepts and processes log records
*
* @name: Name of driver
* @emit: Method to call to emit a log record via this device
* @flags: Initial value for flags (use LOGDF_ENABLE to enable on start-up)
*/
struct log_driver {
const char *name;
......@@ -321,6 +327,7 @@ struct log_driver {
* for processing. The filter is checked before calling this function.
*/
int (*emit)(struct log_device *ldev, struct log_rec *rec);
unsigned short flags;
};
/**
......@@ -333,12 +340,14 @@ struct log_driver {
* @next_filter_num: Seqence number of next filter filter added (0=no filters
* yet). This increments with each new filter on the device, but never
* decrements
* @flags: Flags for this filter (enum log_device_flags)
* @drv: Pointer to driver for this device
* @filter_head: List of filters for this device
* @sibling_node: Next device in the list of all devices
*/
struct log_device {
int next_filter_num;
unsigned short next_filter_num;
unsigned short flags;
struct log_driver *drv;
struct list_head filter_head;
struct list_head sibling_node;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment