plat_log_common.c 649 Bytes
Newer Older
Soby Mathew's avatar
Soby Mathew committed
1
/*
2
 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Soby Mathew's avatar
Soby Mathew committed
3
4
5
6
7
8
9
10
11
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <debug.h>

/* Allow platforms to override the log prefix string */
#pragma weak plat_log_get_prefix

12
static const char *plat_prefix_str[] = {
Soby Mathew's avatar
Soby Mathew committed
13
14
15
16
	"ERROR:   ", "NOTICE:  ", "WARNING: ", "INFO:    ", "VERBOSE: "};

const char *plat_log_get_prefix(unsigned int log_level)
{
17
	unsigned int level;
Soby Mathew's avatar
Soby Mathew committed
18

19
20
21
22
23
24
25
26
27
	if (log_level < LOG_LEVEL_ERROR) {
		level = LOG_LEVEL_ERROR;
	} else if (log_level > LOG_LEVEL_VERBOSE) {
		level = LOG_LEVEL_VERBOSE;
	} else {
		level = log_level;
	}

	return plat_prefix_str[(level / 10U) - 1U];
Soby Mathew's avatar
Soby Mathew committed
28
}