]> Git Repo - u-boot.git/blame - common/log_console.c
Merge branch '2021-02-15-fix-CVE-2021-27097-CVE-2021-27138'
[u-boot.git] / common / log_console.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
c6d47535
SG
2/*
3 * Logging support
4 *
5 * Copyright (c) 2017 Google, Inc
6 * Written by Simon Glass <[email protected]>
c6d47535
SG
7 */
8
9#include <common.h>
10#include <log.h>
401d1c4f 11#include <asm/global_data.h>
c6d47535 12
deca50fb
SG
13DECLARE_GLOBAL_DATA_PTR;
14
c6d47535
SG
15static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
16{
deca50fb
SG
17 int fmt = gd->log_fmt;
18
19 /*
20 * The output format is designed to give someone a fighting chance of
21 * figuring out which field is which:
22 * - level is in CAPS
23 * - cat is lower case and ends with comma
24 * - file normally has a .c extension and ends with a colon
25 * - line is integer and ends with a -
26 * - function is an identifier and ends with ()
27 * - message has a space before it unless it is on its own
28 */
dde173a2 29 if (fmt & BIT(LOGF_LEVEL))
deca50fb 30 printf("%s.", log_get_level_name(rec->level));
dde173a2 31 if (fmt & BIT(LOGF_CAT))
deca50fb 32 printf("%s,", log_get_cat_name(rec->cat));
dde173a2 33 if (fmt & BIT(LOGF_FILE))
deca50fb 34 printf("%s:", rec->file);
dde173a2 35 if (fmt & BIT(LOGF_LINE))
deca50fb 36 printf("%d-", rec->line);
dde173a2 37 if (fmt & BIT(LOGF_FUNC))
deca50fb 38 printf("%s()", rec->func);
dde173a2
HS
39 if (fmt & BIT(LOGF_MSG))
40 printf("%s%s", fmt != BIT(LOGF_MSG) ? " " : "", rec->msg);
c6d47535
SG
41
42 return 0;
43}
44
45LOG_DRIVER(console) = {
46 .name = "console",
47 .emit = log_console_emit,
b4520300 48 .flags = LOGDF_ENABLE,
c6d47535 49};
This page took 0.107867 seconds and 4 git commands to generate.