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> |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 8 | |
| 9 | /* Allow platforms to override the log prefix string */ |
| 10 | #pragma weak plat_log_get_prefix |
| 11 | |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 12 | static const char *plat_prefix_str[] = { |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 13 | "ERROR: ", "NOTICE: ", "WARNING: ", "INFO: ", "VERBOSE: "}; |
| 14 | |
| 15 | const char *plat_log_get_prefix(unsigned int log_level) |
| 16 | { |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 17 | unsigned int level; |
| 18 | |
| 19 | if (log_level < LOG_LEVEL_ERROR) { |
| 20 | level = LOG_LEVEL_ERROR; |
| 21 | } else if (log_level > LOG_LEVEL_VERBOSE) { |
| 22 | level = LOG_LEVEL_VERBOSE; |
| 23 | } else { |
| 24 | level = log_level; |
| 25 | } |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 26 | |
Antonio Nino Diaz | 14fabd0 | 2018-08-28 11:44:44 +0100 | [diff] [blame] | 27 | return plat_prefix_str[(level / 10U) - 1U]; |
Soby Mathew | aaf15f5 | 2017-09-04 11:49:29 +0100 | [diff] [blame] | 28 | } |