1
2
3
4
5
6
7
8
9#include <common.h>
10#include <log.h>
11#include <asm/global_data.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
16{
17 int fmt = gd->log_fmt;
18 bool add_space = false;
19
20
21
22
23
24
25
26
27
28
29
30 if (!(rec->flags & LOGRECF_CONT) && fmt != BIT(LOGF_MSG)) {
31 add_space = true;
32 if (fmt & BIT(LOGF_LEVEL))
33 printf("%s.", log_get_level_name(rec->level));
34 if (fmt & BIT(LOGF_CAT))
35 printf("%s,", log_get_cat_name(rec->cat));
36 if (fmt & BIT(LOGF_FILE))
37 printf("%s:", rec->file);
38 if (fmt & BIT(LOGF_LINE))
39 printf("%d-", rec->line);
40 if (fmt & BIT(LOGF_FUNC))
41 printf("%*s()", CONFIG_LOGF_FUNC_PAD, rec->func);
42 }
43 if (fmt & BIT(LOGF_MSG))
44 printf("%s%s", add_space ? " " : "", rec->msg);
45
46 return 0;
47}
48
49LOG_DRIVER(console) = {
50 .name = "console",
51 .emit = log_console_emit,
52 .flags = LOGDF_ENABLE,
53};
54