]> git.ipfire.org Git - thirdparty/u-boot.git/blame - common/log_console.c
spl: mmc: Report device number when we fail
[thirdparty/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 <sjg@chromium.org>
c6d47535
SG
7 */
8
9#include <common.h>
10#include <log.h>
11
deca50fb
SG
12DECLARE_GLOBAL_DATA_PTR;
13
c6d47535
SG
14static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
15{
deca50fb
SG
16 int fmt = gd->log_fmt;
17
18 /*
19 * The output format is designed to give someone a fighting chance of
20 * figuring out which field is which:
21 * - level is in CAPS
22 * - cat is lower case and ends with comma
23 * - file normally has a .c extension and ends with a colon
24 * - line is integer and ends with a -
25 * - function is an identifier and ends with ()
26 * - message has a space before it unless it is on its own
27 */
28 if (fmt & (1 << LOGF_LEVEL))
29 printf("%s.", log_get_level_name(rec->level));
30 if (fmt & (1 << LOGF_CAT))
31 printf("%s,", log_get_cat_name(rec->cat));
32 if (fmt & (1 << LOGF_FILE))
33 printf("%s:", rec->file);
34 if (fmt & (1 << LOGF_LINE))
35 printf("%d-", rec->line);
36 if (fmt & (1 << LOGF_FUNC))
37 printf("%s()", rec->func);
38 if (fmt & (1 << LOGF_MSG))
39 printf("%s%s", fmt != (1 << LOGF_MSG) ? " " : "", rec->msg);
c6d47535
SG
40
41 return 0;
42}
43
44LOG_DRIVER(console) = {
45 .name = "console",
46 .emit = log_console_emit,
47};