summaryrefslogtreecommitdiffstats
path: root/include/log.h
Commit message (Collapse)AuthorAgeFilesLines
* log: Include missing header for log.hSean Anderson2020-01-071-0/+1
| | | | | | | log.h references cmd_tbl_t but command.h was not included Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: devres: Convert to use loggingSimon Glass2020-01-071-0/+1
| | | | | | | | | | | | | | At present when CONFIG_DEBUG_DEVRES is enabled, U-Boot prints log messages to the console with every devres allocation/free event. This causes most tests to fail since the console output is not as expected. In particular this prevents us from adding a device to sandbox which uses devres in its bind method. Move devres over to use U-Boot's logging feature instead, and add a new category for devres. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Add a noisy assert()Simon Glass2020-01-071-0/+14
| | | | | | | | | | Some U-Boot code uses BUG_ON() and WARN_ON() macros. These use __FILE__ which can include quite a large path, depending on how U-Boot is built. The existing assert() is only checked if DEBUG is enabled. Add a new one which is always checked, and prints a (smaller) error in that case. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add log_nop() to avoid unused-variable warningsSimon Glass2019-10-081-7/+26
| | | | | | | | | If a log statement includes a variable and logging is disabled, this can generate warnings about unused variables. Add a bit more complexity to the macros to avoid this for the common case. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* log: document the assign() macroHeinrich Schuchardt2019-08-071-0/+12
| | | | | | | Provide a concise description of the assert() macro. Point out that the tested expression is always executed, irrespective of the value of _DEBUG. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* log: Allow #define LOG_DEBUG to enable logging in a fileSimon Glass2019-02-201-1/+6
| | | | | | | | | | | At present it is possible to '#define DEBUG' at the top of a file which causes all debug() statements in that file to become active. There is currently no equivalent with logging, but this is a useful function. Add a LOG_DEBUG define along with documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* log: Fix up Kconfig log level namesSimon Glass2019-02-201-1/+1
| | | | | | | | The log level numbers in the Kconfig are not actually correct. Fix them and also add a missing space in the header-file comment. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* log: Check printf() argumentsSimon Glass2019-01-141-1/+2
| | | | | | | At present logging does not check printf() arguments. Now that all users have been corrected, enable this to prevent further problems. Signed-off-by: Simon Glass <sjg@chromium.org>
* malloc_simple: Add logging of allocationsSimon Glass2018-11-291-1/+1
| | | | | | | It is sometimes useful to see what memory is being allocated early during boot. Add logging to support this, using a new LOGC_ALLOC category. Signed-off-by: Simon Glass <sjg@chromium.org>
* Add core support for a bloblist to convey data from SPLSimon Glass2018-11-261-0/+1
| | | | | | | | | | | | | | | | | | | | At present there is no standard way in U-Boot to pass information from SPL to U-Boot proper. But sometimes SPL wants to convey information to U-Boot that U-Boot cannot easily figure out. For example, if SPL sets up SDRAM then it might want to pass the size of SDRAM, or the location of each bank, to U-Boot proper. Add a new 'bloblist' feature which provides this. A bloblist is set up in the first phase of U-Boot that runs (i.e. TPL or SPL). The location of this info may be in SRAM or CAR (x86 cache-as-RAM) or somewhere else. Information placed in this region is preserved (with a checksum) through TPL and SPL and ends up in U-Boot. At this point it is copied into SDRAM so it can be used after relocation. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andreas Dannenberg <dannenberg@ti.com>
* spl: Add support for logging in SPL and TPLSimon Glass2018-11-261-2/+17
| | | | | | | | It is sometimes useful to log information in SPL and TPL. Add support for this. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* sandbox: log: Add a category for sandboxSimon Glass2018-11-201-0/+1
| | | | | | | It seems useful to make sandbox its own log category since it is used for so much testing. Add this as a new category. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add comments to the rest of the log categoriesSimon Glass2018-10-091-6/+6
| | | | | | At present some of the log categories are missing comments. Add them. Signed-off-by: Simon Glass <sjg@chromium.org>
* sandbox: spi: Add more loggingSimon Glass2018-10-091-0/+1
| | | | | | | Add logging to aid debugging features in these drivers. Also drop some code in sandbox_spi_xfer() which is not used. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add helpers for common log levelsSimon Glass2018-10-091-0/+14
| | | | | | | | | | | | | | | | | | | | | At present to output a log message you need something like: log(UCLASS_SPI, LOCL_INFO, "message1"); log(UCLASS_SPI, LOCL_INFO, "message2"); but many files use the same category throughout. Also it is helpful to shorten the length of log names, providing helpers for common logging levels. Add some macros so that it is possible to do: (top of file, before #includes) #define LOG_CATEGORY UCLASS_SPI (later in the file) log_info("message1"); log_debug("message2"); log_err("message3"); Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Correct definition of log_msg_ret()Simon Glass2018-10-081-1/+1
| | | | | | | This macro should have two parameters, not one. Fix it so that it correctly resolves to _ret when logging is disabled. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add a way to log a return value with a messageSimon Glass2018-07-091-0/+8
| | | | | | | | It is sometimes useful to show a message when logging an error return value, perhaps to add a few details about the problem. Add a function to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Fix incorect range check in log_get_cat_name()Simon Glass2018-06-181-1/+2
| | | | | | | This allows access to an element after the end of the array. Fix it. Reported-by: Coverity (CID: 173279) Signed-off-by: Simon Glass <sjg@chromium.org>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* log: fix typo LOGL_EFIHeinrich Schuchardt2018-04-231-1/+1
| | | | | | | | | | According to the documentation the EFI log category is called LOGC_EFI. All other categories start with LOGC_. So let's fix it. Fixes: 1973b381a1b3 ("log: add category LOGC_EFI") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* log: add category LOGC_EFIHeinrich Schuchardt2018-02-031-0/+1
| | | | | | | | | The EFI implementation does not fit into any of the existing categories. Provide LOGC_EFI so that EFI related message can be filtered. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* log: Add a way to log error-return valuesSimon Glass2018-02-031-0/+11
| | | | | | | | | | | | | | | | | | | | When functions return an error it propagates up the stack to the point where it is reported. Often the error code provides enough information about the root cause of the error that this is obvious what went wrong. However in some cases the error may be hard to trace. For example if a driver uses several devices to perform an operation, it may not be obvious which one failed. Add a log_ret() macro to help with this. This can be used to wrap any error-return value. The logging system will then output a log record when the original error is generated, making it easy to trace the call stack of the error. This macro can significantly impact code size, so its use is controlled by a Kconfig option, which is enabled for sandbox. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add control over log formattingSimon Glass2018-02-031-0/+14
| | | | | | | | | It is useful to be able to control the output format of log records on the console. As a starting point, add definitions for controlling which elements of the log record are displayed. Use function and message as the default, since these are the most useful fields. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add functions to convert IDs to/from namesSimon Glass2018-02-031-2/+37
| | | | | | | | | | | | | | Category and level both use an enum for their ID values. Add functions to convert these IDs to strings and vice versa. This will allow the log to output the strings instead of the (inscrutable) values. At the same time, add a new 'driver-model' category, to cover core driver-model functions and fix an incorrect value for LOGL_MAX. Tests will be added with the new 'log' subcommands. Signed-off-by: Simon Glass <sjg@chromium.org> (Updated to correct clang warnings)
* log: Add a test commandSimon Glass2017-12-071-0/+3
| | | | | | Add a command which exercises the logging system. Signed-off-by: Simon Glass <sjg@chromium.org>
* log: Add an implementation of loggingSimon Glass2017-12-071-0/+242
| | | | | | | Add the logging header file and implementation with some configuration options to control it. Signed-off-by: Simon Glass <sjg@chromium.org>
* Move debug and logging support to a separate headerSimon Glass2017-12-071-0/+59
Before adding new features, move these definitions to a separate header to avoid further cluttering common.h. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>