]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - common/log_console.c
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (c) 2017 Google, Inc
6 * Written by Simon Glass <sjg@chromium.org>
10 #include <asm/global_data.h>
12 DECLARE_GLOBAL_DATA_PTR
;
14 static int log_console_emit(struct log_device
*ldev
, struct log_rec
*rec
)
16 int fmt
= gd
->log_fmt
;
17 bool add_space
= false;
20 * The output format is designed to give someone a fighting chance of
21 * figuring out which field is which:
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
29 if (!(rec
->flags
& LOGRECF_CONT
) && fmt
!= BIT(LOGF_MSG
)) {
31 if (fmt
& BIT(LOGF_LEVEL
))
32 printf("%s.", log_get_level_name(rec
->level
));
33 if (fmt
& BIT(LOGF_CAT
))
34 printf("%s,", log_get_cat_name(rec
->cat
));
35 if (fmt
& BIT(LOGF_FILE
))
36 printf("%s:", rec
->file
);
37 if (fmt
& BIT(LOGF_LINE
))
38 printf("%d-", rec
->line
);
39 if (fmt
& BIT(LOGF_FUNC
)) {
40 if (CONFIG_IS_ENABLED(USE_TINY_PRINTF
)) {
41 printf("%s()", rec
->func
);
43 printf("%*s()", CONFIG_LOGF_FUNC_PAD
,
48 if (fmt
& BIT(LOGF_MSG
))
49 printf("%s%s", add_space
? " " : "", rec
->msg
);
54 LOG_DRIVER(console
) = {
56 .emit
= log_console_emit
,
57 .flags
= LOGDF_ENABLE
,