Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 7 | #include <debug.h> |
Yann Gautier | 3364cd4 | 2018-12-10 10:41:03 +0100 | [diff] [blame] | 8 | #include <platform.h> |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 9 | |
| 10 | /* Allow platforms to override the log prefix string */ |
| 11 | #pragma weak plat_log_get_prefix |
| 12 | |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 13 | static const char *plat_prefix_str[] = { |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 14 | "ERROR: ", "NOTICE: ", "WARNING: ", "INFO: ", "VERBOSE: "}; |
| 15 | |
| 16 | const char *plat_log_get_prefix(unsigned int log_level) |
| 17 | { |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 18 | unsigned int level; |
| 19 | |
| 20 | if (log_level < LOG_LEVEL_ERROR) { |
| 21 | level = LOG_LEVEL_ERROR; |
| 22 | } else if (log_level > LOG_LEVEL_VERBOSE) { |
| 23 | level = LOG_LEVEL_VERBOSE; |
| 24 | } else { |
| 25 | level = log_level; |
| 26 | } |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 27 | |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 28 | return plat_prefix_str[(level / 10U) - 1U]; |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 29 | } |