summaryrefslogtreecommitdiff
path: root/include/log.h
AgeCommit message (Collapse)Author
2021-06-08log: Convert log values to printf() if not enabledSimon Glass
At present if logging not enabled, log_info() becomes a nop. But we want log output at the 'info' level to be akin to printf(). Update the macro to pass the output straight to printf() in this case. This mimics the behaviour for the log_...() macros like log_debug() and log_info(), so we can drop the special case for these. Add new tests to cover this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08log: Add support for logging a bufferSimon Glass
The print_buffer() function is very useful for debugging. Add a version of this in the log system also. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-06log: Fix up debug_cond() when LOG is enabledSimon Glass
At present debug() statements can cause debuf output to appear when LOG is enabled but DEBUG is not. This is not intended and it seems that the condition is wrong. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12log: Add return-checking macros for 0 being successSimon Glass
The existing log_ret() and log_msg_ret() macros consider an error to be less than zero. But some function may return a positive number to indicate a different kind of failure. Add macros to check for that also. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12log: Handle line continuationSimon Glass
When multiple log() calls are used which don't end in newline, the log prefix is prepended multiple times in the same line. This makes the output look strange. Fix this by detecting when the previous log record did not end in newline. In that case, setting a flag. Drop the unused BUFFSIZE in the test while we are here. As an example implementation, update log_console to check the flag and produce the expected output. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12log: Set up a flag byte for log recordsSimon Glass
At present only a single flag (force_debug) is used in log records. Before adding more, convert this into a bitfield, so more can be added without using more space. To avoid expanding the log_record struct itself (which some drivers may wish to store in memory) reduce the line-number field to 16 bits. This provides for up to 64K lines which should be enough for anyone. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-16log: provide missing macrosHeinrich Schuchardt
With commit d094a0734cee ("log: allow for message continuation") we have defined a special log level and category for message continuation. Let's have a macro for using these. If logging is enabled log_cont() will create a continuation log output with the same logging level and category as the previous message. If logging is not enabled, log_cont() will print like printf(). Provide macros for logging levels LOG_EMERG, LOG_ALERT, LOG_CRIT. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16log: make debug_cond() function likeHeinrich Schuchardt
Change debug_cond() such that it can be used instead of a function like debug(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-02log: typos in include/log.hHeinrich Schuchardt
Correct several typos. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-02log: Fix comment for LOGC_BOOTSimon Glass
This comment is in the wrong format, so reports an error with 'make htmldocs'. Fix it. Fixes: b73d61a5565 ("x86: zimage: Add a little more logging") Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-11-06x86: zimage: Add a little more loggingSimon Glass
Add logging for each part of the boot process, using a new Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>
2020-10-30doc: Add log kerneldocs to documentationSean Anderson
The functions in log.h are already mostly documented, so add them to the generated documentation. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30cmd: log: Add commands to list categories and driversSean Anderson
This allows users to query which categories and drivers are available on their system. This allows them to construct filter-add commands without (e.g.) adjusting the log format to show categories and drivers. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30log: Add filter flag to match greater than a log levelSean Anderson
This is the complement of the existing behavior to match only messages with a log level less than a threshold. This is primarily useful in conjunction with LOGFF_DENY. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30log: Add filter flag to deny on matchSean Anderson
Without this flag, log filters can only explicitly accept messages. Allowing denial makes it easier to filter certain subsystems. Unlike allow-ing filters, deny-ing filters are added to the beginning of the filter list. This should do the Right Thing most of the time, but it's less-universal than allowing filters to be inserted anywhere. If this becomes a problem, then perhaps log_filter_add* should take a filter number to insert before/after. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30log: Add function to create a filter with flagsSean Anderson
This function exposes a way to specify flags when creating a filter. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30log: Expose some helper functionsSean Anderson
These functions are required by "cmd: log: Add commands to manipulate filters" and "test: Add a test for log filter-*". Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30log: Fix incorrect documentation of log_filter.cat_listSean Anderson
Logging category lists are terminated by LOGC_END, not LOGC_NONE. Fixes: e9c8d49d54 ("log: Add an implementation of logging") Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-10-27log: allow for message continuationHeinrich Schuchardt
Some drivers use macro pr_cont() for continuing a message sent via printk. Hence if we want to convert printk messaging to using the logging system, we must support continuation of log messages too. As pr_cont() does not provide a message level we need a means of remembering the last log level. With the patch a pseudo log level LOGL_CONT as well as a pseudo log category LOGC_CONT are introduced. Using these results in the application of the same log level and category as in the previous log message. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-22log: Add missing category namesSimon Glass
Add some category names that were missed in recent changes. Update the comment as a reminder. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-10log: Add a way to enable/disable a log deviceSimon Glass
At present all log devices are enabled by default. Add a function to allow devices to be disabled or enabled at runtime. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-10log: Add a flag to enable log driversSimon Glass
At present there is no way to disable a log driver. But the syslog driver causes (attempted) network traffic in sandbox every time a log message is printed, which is often. Add a flag to enable a log driver. Adjust struct log_device to use a short for next_filter_num so that no more memory is used for devices. Also fix a missing line in the struct log_driver comment while here. To maintain compatibility, enable it for all drivers for now. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-10log: Allow LOG_DEBUG to always enable log outputSimon Glass
At present if CONFIG_LOG enabled, putting LOG_DEBUG at the top of a file (before log.h inclusion) causes _log() to be executed for every log() call, regardless of the build- or run-time logging level. However there is no guarantee that the log record will actually be displayed. If the current log level is lower than LOGL_DEBUG then it will not be. Add a way to signal that the log record should always be displayed and update log_passes_filters() to handle this. With the new behaviour, log_debug() will always log if LOG_DEBUG is enabled. Move log_test_syslog_nodebug() into its own file since it cannot be made to work where it is, with LOG_DEBUG defined. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-09log: don't show function by defaultHeinrich Schuchardt
The name of the function emitting a log message may be of interest for a developer but is distracting for normal users. See the example below: try_load_entry() Booting: Debian Make the default format for log messages customizable. By default show only the message text. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-05-18command: Remove the cmd_tbl_t typedefSimon Glass
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop net.h from common headerSimon Glass
Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-16Merge tag 'dm-pull-10apr20-take2' of git://git.denx.de/u-boot-dmTom Rini
Functions for reading indexed values from device tree Enhancements to 'dm' command Log test enhancements and syslog driver DM change to read parent ofdata before children Minor fixes
2020-04-16log: output for CONFIG_LOG=nHeinrich Schuchardt
If CONFIG_LOG=n, we should still output errors, warnings, notices, infos, and for DEBUG=1 also debug messages. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16dm: core: Add basic ACPI supportSimon Glass
ACPI (Advanced Configuration and Power Interface) is a standard for specifying information about a platform. It is a little like device tree but the bindings are part of the specification and it supports an interpreted bytecode language. Driver model does not use ACPI for U-Boot's configuration, but it is convenient to have it support generation of ACPI tables for passing to Linux, etc. As a starting point, add an optional set of ACPI operations to each device. Initially only a single operation is available, to obtain the ACPI name for the device. More operations are added later. Enable ACPI for sandbox to ensure build coverage and so that we can add tests. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2020-01-07log: Include missing header for log.hSean Anderson
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>
2020-01-07dm: devres: Convert to use loggingSimon Glass
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>
2020-01-07common: Add a noisy assert()Simon Glass
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>
2019-10-08log: Add log_nop() to avoid unused-variable warningsSimon Glass
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>
2019-08-07log: document the assign() macroHeinrich Schuchardt
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>
2019-02-20log: Allow #define LOG_DEBUG to enable logging in a fileSimon Glass
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>
2019-02-20log: Fix up Kconfig log level namesSimon Glass
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>
2019-01-14log: Check printf() argumentsSimon Glass
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>
2018-11-29malloc_simple: Add logging of allocationsSimon Glass
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>
2018-11-26Add core support for a bloblist to convey data from SPLSimon Glass
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>
2018-11-26spl: Add support for logging in SPL and TPLSimon Glass
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>
2018-11-20sandbox: log: Add a category for sandboxSimon Glass
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>
2018-10-09log: Add comments to the rest of the log categoriesSimon Glass
At present some of the log categories are missing comments. Add them. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09sandbox: spi: Add more loggingSimon Glass
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>
2018-10-09log: Add helpers for common log levelsSimon Glass
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>
2018-10-08log: Correct definition of log_msg_ret()Simon Glass
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>
2018-07-09log: Add a way to log a return value with a messageSimon Glass
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>
2018-06-18log: Fix incorect range check in log_get_cat_name()Simon Glass
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>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
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>
2018-04-23log: fix typo LOGL_EFIHeinrich Schuchardt
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>
2018-02-03log: add category LOGC_EFIHeinrich Schuchardt
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>