Logging v2 supports 255 arguments but since logging v1 was supporting
only 15, and it is still compiled, more than 15 could not be used.
Extending logging v1 macro to accept up to 31 arguments. It will fail
during processing in case of v1 but will work with v2 enabled. It is
a temporary solution since v1 will be removed at some point.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add flags to macro which checks if string must be packaged
using runtime approach.
Added flag CBPRINTF_MUST_RUNTIME_PACKAGE_CONST_CHAR. When flag
is set then const char pointers are considered as pointers to
fixed strings and do not require runtime packaging.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add function which can be used to check if there is any pending
data to process. It can be used to determine if deferred logging
has completed processing.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Remove LOG_MINIMAL kconfig option which was confusing
since LOG_MODE_MINIMAL existed. LOG_MINIMAL was used to
force minimal mode but because of invalid dependencies
it was leading to issues.
Refactored code to use LOG_MODE_MINIMAL everywhere and
renamed LOG_MINIMAL to LOG_DEFAULT_MINIMAL which has impact
on defualt logging mode (which still can be later changed
in conf file or in menuconfig).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
There were some leftovers in logging after attempt to use
logging as tracing backend. Removing all references since it
lead to test compilation failures.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added log_internal.h for internal APIs. Move functions out of
log_core.h. Log_core.h shall have only macros and functions related
to logging message creation. Log_core.h is included by log.h thus
number of dependencies in that headers must be limited to minimum
to allow including without risk of circular dependencies.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:
Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add the number of strdup buffers currently in use to the
`log strdup_utilization` shell command.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
Extract functions which are managing logging sources
and backends into separate file: log_mgmt.
So far those functions were in log_core mixed with functions
specific to log message creation and log processing.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added support for conversion from a standard package which contains
pointers to read only strings to fully self-contained (fsc) package.
Fsc package contains all strings associated with the package thus
access to read only strings is not needed to format a string.
In order to allow conversion to fsc package, standard package must
contain locations of all string pointers within the package. Appending
that information is optional and is controlled by flags parameter
which was added to packaging API. If option flag is set then
package contains header, arguments, locations of read only strings and
transient strings (each prefixed with string argument location).
Package header has been extended with field which contains number of
read only string locations.
A function for conversion to fsc package has been added
(cbprintf_fsc_package()).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
log_backend_std_put had its own implementation for getting standard
flags which was identical to the one in log_backend_std_get_flags().
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Recent rework in logging api brings complicated macros which can
overhelm Eclipse CDT parser.
This workaround disables expansion of LOG_xxx macros in Eclipse.
Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
Remove dead code enum tracing_log_id
Not used anywhere in the code. Also it caused MISRA rule 8.12
violation.
Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
C++ compiliation may generate warning if some fields are not
explicitly initialized. Added explicit initialization to 0.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add empty Z_LOG_MSG2_SIMPLE_CREATE when CONFIG_LOG_SPEED=n. It
allows to reduce compilation time by removing code at preprocessor
stage. Previously functionality was the same, compiler was removing
unused code but because logging is widely use that had a visible
impact on compile time.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Simplified handling of runtime filtering that lead to removal
of LOG_CHECK_CTX_LVL_FILTER macro. Fixing multiply coverity issues
like CID 236013.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This adds dictionary based logging support. Dictionary based
logging is binary based where one big difference is that
static strings are stored as pointers instead of the whole
string. This results in reduced space requirements for
storing log messages in certain scenairos.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When printk is redirected to the logging it is using level 0.
Level 0 was missing a define used for detection of function
prefix use which lead to compilation failure when logging v2
was used with CONFIG_LOG_PRINTK=y.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Arguments for UTIL_CAT were accidentaly concatenated instead of passed
separated by comma.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logging attempts to do most of the work at compile time instead
of preprocessor by using conditions which can be resolved at
compile time (e.g. if (IS_ENABLED(...))). Apparently, such extensive
use significantly loads the compiler since all paths are compiled
even though cut from final binary. Patch reduces it by replacing
some compile time switch with preprocessor.
Handling of function name prefix has been moved to preprocessor.
Immediate logging v2 has also been moved to preprocessor.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
So far we only have log_msg_timestamp_get() function, which returns
internal timestamp representation. This is either clock cycles or uptime
in ms, depending on main clock precision.
Introduce log_output_timestamp_to_us() helper function, which allows to
convert internal logging timestamp to us.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Added macro which allows to print formatted string using
logging infrastructure.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added implementation of log_msg2 which is creating log messages
using cbprintf packaging and storing them in circular ring buffer
(mpsg_pbuf).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This functions is being called across the tree, no reason why it should
not be a public API.
The current usage violates a few MISRA rules.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Removed printk.h include from log_core.h.
Since LOG_PRINTK cannot be enabled with LOG_MINIMAL removed
support for both.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Said warning comes when building with LOG_MODE_MINIMAL and
including logging/log.h. This commit adds ARG_UNUSED on
relevant variables.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
The proper usage of @param in callbacks is currently unsupported by
Doxygen so not warnings are generated. The issues fixed with this commit
where found while adding support to Doxygen for validating @param in
callbacks like it currently does for functions.
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
Exported header oftenly used when creating a logging
backend that inpects the log 'stream'.
Enables use in external Zephyr modules implementing the
logging backend interface.
Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
The logging subsytsem had if else if constructs without final
else statement. This commit adds else {} to comply with
coding guideline 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
Change a runtime log check such that Coverity does not report a
needless issue on every use of any log macro.
Before the change, this was used in log macros:
else if(is_user_context || (_level <= LOG_RUNTIME_FILTER(_filter)))
If runtime filtering is not enabled, this expands to:
else if(is_user_context || 1)
Because the level is compared to log level debug (4) and will always be,
equal or lower.
Coverity always reports this as a potential issue, since the
variable part (is_user_context) makes no difference.
After the change, a macro is used which expands into the original code
when runtime filtering is used, else it simply expands to:
else if(true)
Which has equal semantics as the previous code but isn't flagged by
Coverity.
Signed-off-by: Torstein Grindvik <torstein.grindvik@nordicsemi.no>
Both operands of an operator in the arithmetic conversions
performed shall have the same essential type category.
Changes are related to converting the integer constants to the
unsigned integer constants
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
MISRA-C Directive 4.7 says that error information returned from
a function needs to be tested. In the logging macros,
return from _is_user_context() is not needed until logging is
enabled and above minimal logging level. There is a potential
that the return is not being used at all. So move it one level
below as it is surely being used within the if block.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Added initialization of ids fields in the log message in
z_log_msg_std_alloc(). If user space is enabled then msg_free()
function is reading log level and previously it may have been
uninitialized.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Introduced interface for efficient logging from external logsystems:
Added handling of vaargs and automatic strdup to macros intended
to be used in logging interface function. Fast path to less then 4
arguments to speed up the execution. Made log_count_args external,
if external logsystem cannot count arguments.
Signed-off-by: Tomasz Konieczny <tomasz.konieczny@nordicsemi.no>