Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional attributes for log messages #1022

Closed
wants to merge 61 commits into from

Conversation

sergeuz
Copy link
Member

@sergeuz sergeuz commented Jun 9, 2016

This PR implements LOG_ATTR() macro which allows to specify additional attributes for log messages. For example:

wiced_result_t result = wiced_init();
if (result != WICED_SUCCESS) {
    LOG_ATTR(ERROR, (code = result, detail = "wiced"), "Initialization error");
}

int error = mbedtls_rsa_gen_key(&rsa_ctx, rng_func, 1024, 65537);
if (error) {
    LOG_ATTR(ERROR, (code = error, detail = "mbedtls"), "Unable to generate keys");
}

Only code and detail attributes are supported at the moment. New attributes (e.g. thread ID), can be easily added by extending LogAttributes structure.

The implementation involves a bit of preprocessor magic in order to support named parameters syntax in both C and C++, so this patch also adds small header file with some typical preprocessor primitives (see services/inc/preprocessor.h). In principle, the same could be easily implemented using Boost.Preprocessor, I just wasn't sure if we want to introduce additional compile-time dependency for the firmware build.

Note that this patch is based on the feature/logger_api branch and introduces ABI breaking changes to the existent dynalib interface of the logging library. It is likely too late to include this patch into upcoming 0.6.0, so I would mark current logging API as "experimental and subject to change" in the develop and postpone publishing of the logging API reference until next release.


  • Contributor has signed CLA
  • Problem and Solution clearly stated
  • Code peer reviewed
  • API tests compiled
  • Run unit/integration/application tests on device
  • Add documentation
  • Add to CHANGELOG.md after merging (add links to docs and issues)

avtolstoy and others added 18 commits May 5, 2016 03:39
… the actual socket to be passed since this may be needed by some implementations (e.g. gcc.)
…vior in general

Test SERIAL1_AvailableForWriteWorksCorrectly added to wiring/serial_loopback
…he correct address.) This allows potentially a 256k user firmware image to be used instead of a factory reset image. (And a 256k OTA image starting at 0x80C0000).
…efore it can be used (or the length field is 0, despite being a constant.) It's called from HAL_Core_Config to set up the location of the factory firmware, which is the key trigger for a factory reset in the bootloader. However, since the DCD wasn't initialized any attempts to write to the DCD before it was constructed would fail - the write offset was checked against the length (which is 0.)

The fix is to create a static function instance so that it's constructed on first use, independent from global object construction.
@m-mcgowan m-mcgowan added this to the 0.6.x milestone Jun 10, 2016
@m-mcgowan
Copy link
Contributor

I took a quick look at the code, namely the LogAttributes and the new interface. It would be good to get this in since it's quite extensible, and provides a good stable base for the logging API. Anyone have bandwidth to review in detail?

Fixes USARTSerial::availableForWrite() behavior
@sergeuz sergeuz mentioned this pull request Jun 10, 2016
7 tasks
technobly and others added 8 commits June 10, 2016 11:57
* Save PinMode in STM32_PIN_MAP.user_property (HAL_GPIO_Save_Pin_Mode/HAL_GPIO_Recall_Pin_Mode)
* adds https://github.com/spark/firmware/issues/993 to changelog
* adds TCP server implementation for gcc platform.

* ensures that output is unbuffered, so that gcc standard output can be consumed by a process expecting a given protocol.

* the weak setup/loop are not required with the gcc platform (including them can cause the intended setup/loop functions to be not linked.)

* changelog
* makes the os_queue interface extensible, and exposes it to the dynamic library.
* adds eeprom support for virtual devices
* Enable bootloader OTA updates on Electron, disabled by removal of bootloader image from system-part2
@m-mcgowan
Copy link
Contributor

@sergeuz - any thoughts on how the log attributes can be added to the Wiring logging API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants