17aafb12eSNagaraju Goruganti# phosphor-logging 2c41693c6SMatt SpinlerThe phosphor logging repository provides mechanisms for event and journal 3c41693c6SMatt Spinlerlogging. 4c41693c6SMatt Spinler 5c41693c6SMatt Spinler## Table Of Contents 6c41693c6SMatt Spinler* [Building](#to-build) 7*87896d58SPatrick Williams* [Structured Logging](#structured-logging) 80a2c1a23SMatt Spinler* [Event Logs](#event-logs) 9c41693c6SMatt Spinler* [Application Specific Error YAML](#adding-application-specific-error-yaml) 10c41693c6SMatt Spinler* [Event Log Extensions](#event-log-extensions) 1124eb160fSJeremy Kerr* [Remote Logging](#remote-logging-via-rsyslog) 120649b985SAndrew Geissler* [Boot Fail on Hardware Errors](#boot-fail-on-hardware-errors) 137aafb12eSNagaraju Goruganti 147aafb12eSNagaraju Goruganti## To Build 157aafb12eSNagaraju GorugantiTo build this package, do the following steps: 167aafb12eSNagaraju Goruganti 177bc39084SPatrick Williams1. meson builddir 187bc39084SPatrick Williams2. ninja -c builddir 199067c077SDeepak Kodihalli 20*87896d58SPatrick Williams## Structured Logging 21*87896d58SPatrick Williamsphosphor-logging provides APIs to add program logging information to the 22*87896d58SPatrick Williamssystemd-journal and it is preferred that this logging data is formatted in 23*87896d58SPatrick Williamsa structured manner (using the facilities provided by the APIs). 24*87896d58SPatrick Williams 25*87896d58SPatrick WilliamsSee [Structured Logging](./docs/structured-logging.md) for more details on 26*87896d58SPatrick Williamsthis API. 27*87896d58SPatrick Williams 280a2c1a23SMatt Spinler## Event Logs 290a2c1a23SMatt SpinlerOpenBMC event logs are a collection of D-Bus interfaces owned by 300a2c1a23SMatt Spinlerphosphor-log-manager that reside at `/xyz/openbmc_project/logging/entry/X`, 310a2c1a23SMatt Spinlerwhere X starts at 1 and is incremented for each new log. 320a2c1a23SMatt Spinler 330a2c1a23SMatt SpinlerThe interfaces are: 340a2c1a23SMatt Spinler* [xyz.openbmc_project.Logging.Entry] 350a2c1a23SMatt Spinler * The main event log interface. 3627d82814SJohn Wang* [xyz.openbmc_project.Association.Definitions] 370a2c1a23SMatt Spinler * Used for specifying inventory items as the cause of the event. 380a2c1a23SMatt Spinler * For more information on associations, see [here][associations-doc]. 390a2c1a23SMatt Spinler* [xyz.openbmc_project.Object.Delete] 400a2c1a23SMatt Spinler * Provides a Delete method to delete the event. 410a2c1a23SMatt Spinler* [xyz.openbmc_project.Software.Version] 420a2c1a23SMatt Spinler * Stores the code version that the error occurred on. 430a2c1a23SMatt Spinler 440a2c1a23SMatt SpinlerOn platforms that make use of these event logs, the intent is that they are 450a2c1a23SMatt Spinlerthe common event log representation that other types of event logs can be 460a2c1a23SMatt Spinlercreated from. For example, there is code to convert these into both Redfish 470a2c1a23SMatt Spinlerand IPMI event logs, in addition to the event log extensions mentioned 480a2c1a23SMatt Spinler[below](#event-log-extensions). 490a2c1a23SMatt Spinler 500a2c1a23SMatt SpinlerThe logging daemon has the ability to add `callout` associations to an event 510a2c1a23SMatt Spinlerlog based on text in the AdditionalData property. A callout is a link to the 520a2c1a23SMatt Spinlerinventory item(s) that were the cause of the event log. See [here][callout-doc] 530a2c1a23SMatt Spinlerfor details. 540a2c1a23SMatt Spinler 550a2c1a23SMatt Spinler### Creating Event Logs In Code 560a2c1a23SMatt SpinlerThere are two approaches to creating event logs in OpenBMC code. The first 570a2c1a23SMatt Spinlermakes use of the systemd journal to store metadata needed for the log, and the 580a2c1a23SMatt Spinlersecond is a plain D-Bus method call. 590a2c1a23SMatt Spinler 600a2c1a23SMatt Spinler#### Journal Based Event Log Creation 610a2c1a23SMatt SpinlerEvent logs can be created by using phosphor-logging APIs to commit sdbusplus 620a2c1a23SMatt Spinlerexceptions. These APIs write to the journal, and then call a `Commit` 630a2c1a23SMatt SpinlerD-Bus method on the logging daemon to create the event log using the information 640a2c1a23SMatt Spinlerit put in the journal. 650a2c1a23SMatt Spinler 660a2c1a23SMatt SpinlerThe APIs are found in `<phosphor-logging/elog.hpp>`: 670a2c1a23SMatt Spinler* `elog()`: Throw an sdbusplus error. 680a2c1a23SMatt Spinler* `commit()`: Catch an error thrown by elog(), and commit it to create the 690a2c1a23SMatt Spinler event log. 700a2c1a23SMatt Spinler* `report()`: Create an event log from an sdbusplus error without throwing the 710a2c1a23SMatt Spinler exception first. 720a2c1a23SMatt Spinler 730a2c1a23SMatt SpinlerAny errors passed into these APIs must be known to phosphor-logging, usually 740a2c1a23SMatt Spinlerby being defined in `<phosphor-logging/elog-errors.hpp>`. The errors must 750a2c1a23SMatt Spinleralso be known by sdbusplus, and be defined in their corresponding error.hpp. 760a2c1a23SMatt SpinlerSee below for details on how get errors into these headers. 770a2c1a23SMatt Spinler 780a2c1a23SMatt SpinlerExample: 790a2c1a23SMatt Spinler``` 800a2c1a23SMatt Spinler#include <phosphor-logging/elog-errors.hpp> 810a2c1a23SMatt Spinler#include <phosphor-logging/elog.hpp> 820a2c1a23SMatt Spinler#include <xyz/openbmc_project/Common/error.hpp> 830a2c1a23SMatt Spinler... 840a2c1a23SMatt Spinlerusing InternalFailure = 850a2c1a23SMatt Spinler sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 860a2c1a23SMatt Spinler... 870a2c1a23SMatt Spinlerif (somethingBadHappened) 880a2c1a23SMatt Spinler{ 890a2c1a23SMatt Spinler phosphor::logging::report<InternalFailure>(); 900a2c1a23SMatt Spinler} 910a2c1a23SMatt Spinler 920a2c1a23SMatt Spinler``` 930a2c1a23SMatt SpinlerAlternatively, to throw, catch, and then commit the error: 940a2c1a23SMatt Spinler``` 950a2c1a23SMatt Spinlertry 960a2c1a23SMatt Spinler{ 970a2c1a23SMatt Spinler phosphor::logging::elog<InternalFailure>(); 980a2c1a23SMatt Spinler} 990a2c1a23SMatt Spinlercatch (InternalFailure& e) 1000a2c1a23SMatt Spinler{ 1010a2c1a23SMatt Spinler phosphor::logging::commit<InternalFailure>(); 1020a2c1a23SMatt Spinler} 1030a2c1a23SMatt Spinler``` 1040a2c1a23SMatt Spinler 1050a2c1a23SMatt SpinlerMetadata can be added to event logs to add debug data captured at the time of 1060a2c1a23SMatt Spinlerthe event. It shows up in the AdditionalData property in the 1070a2c1a23SMatt Spinler`xyz.openbmc_project.Logging.Entry` interface. Metadata is passed in via the 1080a2c1a23SMatt Spinler`elog()` or `report()` functions, which write it to the journal. The metadata 1090a2c1a23SMatt Spinlermust be predefined for the error in the [metadata YAML](#event-log-definition) 1100a2c1a23SMatt Spinlerso that the daemon knows to look for it in the journal when it creates the 1110a2c1a23SMatt Spinlerevent log. 1120a2c1a23SMatt Spinler 1130a2c1a23SMatt SpinlerExample: 1140a2c1a23SMatt Spinler``` 1150a2c1a23SMatt Spinler#include <phosphor-logging/elog-errors.hpp> 1160a2c1a23SMatt Spinler#include <phosphor-logging/elog.hpp> 1170a2c1a23SMatt Spinler#include <xyz/openbmc_project/Control/Device/error.hpp> 1180a2c1a23SMatt Spinler... 1190a2c1a23SMatt Spinlerusing WriteFailure = 1200a2c1a23SMatt Spinler sdbusplus::xyz::openbmc_project::Control::Device::Error::WriteFailure; 1210a2c1a23SMatt Spinlerusing metadata = 1220a2c1a23SMatt Spinler xyz::openbmc_project::Control::Device::WriteFailure; 1230a2c1a23SMatt Spinler... 1240a2c1a23SMatt Spinlerif (somethingBadHappened) 1250a2c1a23SMatt Spinler{ 1260a2c1a23SMatt Spinler phosphor::logging::report<WriteFailure>(metadata::CALLOUT_ERRNO(5), 1270a2c1a23SMatt Spinler metadata::CALLOUT_DEVICE_PATH("some path")); 1280a2c1a23SMatt Spinler} 1290a2c1a23SMatt Spinler``` 1300a2c1a23SMatt SpinlerIn the above example, the AdditionalData property would look like: 1310a2c1a23SMatt Spinler``` 1320a2c1a23SMatt Spinler["CALLOUT_ERRNO=5", "CALLOUT_DEVICE_PATH=some path"] 1330a2c1a23SMatt Spinler``` 1340a2c1a23SMatt SpinlerNote that the metadata fields must be all uppercase. 1350a2c1a23SMatt Spinler 1360a2c1a23SMatt Spinler##### Event Log Definition 1370a2c1a23SMatt SpinlerAs mentioned above, both sdbusplus and phosphor-logging must know about the 1380a2c1a23SMatt Spinlerevent logs in their header files, or the code that uses them will not even 1390a2c1a23SMatt Spinlercompile. The standard way to do this to define the event in the appropriate 1400a2c1a23SMatt Spinler`<error-category>.errors.yaml` file, and define any metadata in the 1410a2c1a23SMatt Spinler`<error-category>.metadata.yaml` file in the appropriate `*-dbus-interfaces` 1420a2c1a23SMatt Spinlerrepository. During the build, phosphor-logging generates the elog-errors.hpp 1430a2c1a23SMatt Spinlerfile for use by the calling code. 1440a2c1a23SMatt Spinler 1450a2c1a23SMatt SpinlerIn much the same way, sdbusplus uses the event log definitions to generate an 1460a2c1a23SMatt Spinlererror.hpp file that contains the specific exception. The path of the error.hpp 1470a2c1a23SMatt Spinlermatches the path of the YAML file. 1480a2c1a23SMatt Spinler 1490a2c1a23SMatt SpinlerFor example, if in phosphor-dbus-interfaces there is 1500a2c1a23SMatt Spinler`xyz/openbmc_project/Control/Device.errors.yaml`, the errors that come from 1510a2c1a23SMatt Spinlerthat file will be in the include: 1520a2c1a23SMatt Spinler`xyz/openbmc_project/Control/Device/error.hpp`. 1530a2c1a23SMatt Spinler 1540a2c1a23SMatt SpinlerIn rare cases, one may want one to define their errors in the same repository 1550a2c1a23SMatt Spinlerthat uses them. To do that, one must: 1560a2c1a23SMatt Spinler 1570a2c1a23SMatt Spinler1. Add the error and metadata YAML files to the repository. 1580a2c1a23SMatt Spinler2. Run the sdbus++ script within the makefile to create the error.hpp and .cpp 1590a2c1a23SMatt Spinler files from the local YAML, and include the error.cpp file in the application 1600a2c1a23SMatt Spinler that uses it. See [openpower-occ-control] for an example. 1610a2c1a23SMatt Spinler3. Tell phosphor-logging about the error. This is done by either: 1620a2c1a23SMatt Spinler * Following the [directions](#adding-application-specific-error-yaml) 1630a2c1a23SMatt Spinler defined in this README, or 1640a2c1a23SMatt Spinler * Running the script yourself: 1650a2c1a23SMatt Spinler 1. Run phosphor-logging\'s `elog-gen.py` script on the local yaml to 1660a2c1a23SMatt Spinler generate an elog-errors.hpp file that just contains the local errors, 1670a2c1a23SMatt Spinler and check that into the repository and include it where the errors are 1680a2c1a23SMatt Spinler needed. 1690a2c1a23SMatt Spinler 2. Create a recipe that copies the local YAML files to a place that 1700a2c1a23SMatt Spinler phosphor-logging can find it during the build. See [here][led-link] 1710a2c1a23SMatt Spinler for an example. 1720a2c1a23SMatt Spinler 1730a2c1a23SMatt Spinler#### D-Bus Event Log Creation 17472575f51SMatt SpinlerThere is also a [D-Bus method][log-create-link] to create event logs: 17572575f51SMatt Spinler* Service: xyz.openbmc_project.Logging 17672575f51SMatt Spinler* Object Path: /xyz/openbmc_project/logging 17772575f51SMatt Spinler* Interface: xyz.openbmc_project.Logging.Create 17872575f51SMatt Spinler* Method: Create 17972575f51SMatt Spinler * Method Arguments: 18072575f51SMatt Spinler * Message: The `Message` string property for the 18172575f51SMatt Spinler `xyz.openbmc_project.Logging.Entry` interface. 18272575f51SMatt Spinler * Severity: The `severity` property for the 18372575f51SMatt Spinler `xyz.openbmc_project.Logging.Entry` interface. 18472575f51SMatt Spinler An `xyz.openbmc_project.Logging.Entry.Level` enum value. 18572575f51SMatt Spinler * AdditionalData: The `AdditionalData` property for the 18672575f51SMatt Spinler `xyz.openbmc_project.Logging.Entry` interface, but in a map 18772575f51SMatt Spinler instead of in a vector of "KEY=VALUE" strings. 18872575f51SMatt Spinler Example: 18972575f51SMatt Spinler``` 19072575f51SMatt Spinler std::map<std::string, std::string> additionalData; 19172575f51SMatt Spinler additionalData["KEY"] = "VALUE"; 19272575f51SMatt Spinler``` 19372575f51SMatt Spinler 19472575f51SMatt Spinler 19572575f51SMatt SpinlerUnlike the previous APIs where errors could also act as exceptions that could 19672575f51SMatt Spinlerbe thrown across D-Bus, this API does not require that the error be defined in 19772575f51SMatt Spinlerthe error YAML in the D-Bus interfaces repository so that sdbusplus knows about 19872575f51SMatt Spinlerit. Additionally, as this method passes in everything needed to create the 19972575f51SMatt Spinlerevent log, the logging daemon doesn't have to know about it ahead of time 20072575f51SMatt Spinlereither. 20172575f51SMatt Spinler 20272575f51SMatt SpinlerThat being said, it is recommended that users of this API still follow some 20372575f51SMatt Spinlerguidelines for the message field, which is normally generated from a 20472575f51SMatt Spinlercombination of the path to the error YAML file and the error name itself. For 20572575f51SMatt Spinlerexample, the `Timeout` error in `xyz/openbmc_project/Common.errors.yaml` will 20672575f51SMatt Spinlerhave a Message property of `xyz.openbmc_project.Common.Error.Timeout`. 20772575f51SMatt Spinler 20872575f51SMatt SpinlerThe guidelines are: 20972575f51SMatt Spinler1. When it makes sense, one can still use an existing error that has already 21072575f51SMatt Spinler been defined in an error YAML file, and use the same severity and metadata 21172575f51SMatt Spinler (AdditionalData) as in the corresponding metadata YAML file. 21272575f51SMatt Spinler 21372575f51SMatt Spinler2. If creating a new error, use the same naming scheme as other errors, which 21472575f51SMatt Spinler starts with the domain, `xyz.openbmc_project`, `org.open_power`, etc, 21572575f51SMatt Spinler followed by the capitalized category values, followed by `Error`, followed 21672575f51SMatt Spinler by the capitalized error name itself, with everything separated by "."s. 21772575f51SMatt Spinler For example: `xyz.openbmc_project.Some.Category.Error.Name`. 21872575f51SMatt Spinler 21972575f51SMatt Spinler3. If creating a new common error, still add it to the appropriate error and 22072575f51SMatt Spinler metadata YAML files in the appropriate D-Bus interfaces repository so that 22172575f51SMatt Spinler others can know about it and use it in the future. This can be done after 22272575f51SMatt Spinler the fact. 2230a2c1a23SMatt Spinler 2240a2c1a23SMatt Spinler[xyz.openbmc_project.Logging.Entry]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Logging/Entry.interface.yaml 22527d82814SJohn Wang[xyz.openbmc_project.Association.Definitions]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Association/Definitions.interface.yaml 226828c4835SGunnar Mills[associations-doc]: https://github.com/openbmc/docs/blob/master/architecture/object-mapper.md#associations 2270a2c1a23SMatt Spinler[callout-doc]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Common/Callout/README.md 2280a2c1a23SMatt Spinler[xyz.openbmc_project.Object.Delete]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Object/Delete.interface.yaml 2290a2c1a23SMatt Spinler[xyz.openbmc_project.Software.Version]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Software/Version.errors.yaml 2300a2c1a23SMatt Spinler[elog-errors.hpp]: https://github.com/openbmc/phosphor-logging/blob/master/phosphor-logging/elog.hpp 2310a2c1a23SMatt Spinler[openpower-occ-control]: https://github.com/openbmc/openpower-occ-control 2320a2c1a23SMatt Spinler[led-link]: https://github.com/openbmc/openbmc/tree/master/meta-phosphor/recipes-phosphor/leds 23372575f51SMatt Spinler[log-create-link]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Logging/Create.interface.yaml 2340febd26bSDeepak Kodihalli 2359067c077SDeepak Kodihalli## Adding application specific error YAML 2364e5f521aSMarri Devender Rao* This document captures steps for adding application specific error YAML files 2374e5f521aSMarri Devender Rao and generating local elog-errors.hpp header file for application use. 2384e5f521aSMarri Devender Rao* Should cater for continuous integration (CI) build, bitbake image build, and 2394e5f521aSMarri Devender Rao local repository build. 2407aafb12eSNagaraju Goruganti 2419067c077SDeepak Kodihalli#### Continuous Integration (CI) build 2424e5f521aSMarri Devender Rao * Make is called on the repository that is modified. 2434e5f521aSMarri Devender Rao * Dependent packages are pulled based on the dependency list specified in the 2444e5f521aSMarri Devender Rao configure.ac script. 2457aafb12eSNagaraju Goruganti 2469067c077SDeepak Kodihalli#### Recipe build 2474e5f521aSMarri Devender Rao * Native recipes copy error YAML files to shared location. 2484e5f521aSMarri Devender Rao * phosphor-logging builds elog-errors.hpp by parsing the error YAML files from 2494e5f521aSMarri Devender Rao the shared location. 2507aafb12eSNagaraju Goruganti 2519067c077SDeepak Kodihalli#### Local repository build 2524e5f521aSMarri Devender Rao * Copies local error YAML files to the shared location in SDK 2534e5f521aSMarri Devender Rao * Make generates elog-errors.hpp by parsing the error YAML files from the 2544e5f521aSMarri Devender Rao shared location. 2557aafb12eSNagaraju Goruganti 2569067c077SDeepak Kodihalli#### Makefile changes 2574e5f521aSMarri Devender Rao**Reference** 2584e5f521aSMarri Devender Rao * https://github.com/openbmc/openpower-debug-collector/blob/master/Makefile.am 2599067c077SDeepak Kodihalli 2609067c077SDeepak Kodihalli###### Export error YAML to shared location 2614e5f521aSMarri Devender Rao*Modify Makefile.am to export newly added error YAML to shared location* 2624e5f521aSMarri Devender Rao``` 2634e5f521aSMarri Devender Raoyamldir = ${datadir}/phosphor-dbus-yaml/yaml 2644e5f521aSMarri Devender Raonobase_yaml_DATA = \ 2654e5f521aSMarri Devender Rao org/open_power/Host.errors.yaml 2664e5f521aSMarri Devender Rao``` 2679067c077SDeepak Kodihalli 2689067c077SDeepak Kodihalli###### Generate elog-errors.hpp using elog parser from SDK location 2694e5f521aSMarri Devender Rao * Add a conditional check "GEN_ERRORS" 2704e5f521aSMarri Devender Rao * Disable the check for recipe bitbake image build 2714e5f521aSMarri Devender Rao * Enable it for local repository build 2724e5f521aSMarri Devender Rao * If "GEN_ERRORS" is enabled, build generates elog-errors.hpp header file. 2734e5f521aSMarri Devender Rao``` 2744e5f521aSMarri Devender Rao # Generate phosphor-logging/elog-errors.hpp 2754e5f521aSMarri Devender Rao if GEN_ERRORS 2764e5f521aSMarri Devender Rao ELOG_MAKO ?= elog-gen-template.mako.hpp 2774e5f521aSMarri Devender Rao ELOG_DIR ?= ${OECORE_NATIVE_SYSROOT}${datadir}/phosphor-logging/elog 2784e5f521aSMarri Devender Rao ELOG_GEN_DIR ?= ${ELOG_DIR}/tools/ 2794e5f521aSMarri Devender Rao ELOG_MAKO_DIR ?= ${ELOG_DIR}/tools/phosphor-logging/templates/ 2804e5f521aSMarri Devender Rao YAML_DIR ?= ${OECORE_NATIVE_SYSROOT}${datadir}/phosphor-dbus-yaml/yaml 2814e5f521aSMarri Devender Rao phosphor-logging/elog-errors.hpp: 2824e5f521aSMarri Devender Rao @mkdir -p ${YAML_DIR}/org/open_power/ 2834e5f521aSMarri Devender Rao @cp ${top_srcdir}/org/open_power/Host.errors.yaml \ 2844e5f521aSMarri Devender Rao ${YAML_DIR}/org/open_power/Host.errors.yaml 2854e5f521aSMarri Devender Rao @mkdir -p `dirname $@` 2864e5f521aSMarri Devender Rao @chmod 777 $(ELOG_GEN_DIR)/elog-gen.py 2874e5f521aSMarri Devender Rao $(AM_V_at)$(PYTHON) $(ELOG_GEN_DIR)/elog-gen.py -y ${YAML_DIR} \ 2884e5f521aSMarri Devender Rao -t ${ELOG_MAKO_DIR} -m ${ELOG_MAKO} -o $@ 2894e5f521aSMarri Devender Rao endif 2904e5f521aSMarri Devender Rao``` 2917aafb12eSNagaraju Goruganti 2929067c077SDeepak Kodihalli###### Update BUILT_SOURCES 2934e5f521aSMarri Devender Rao * Append elog-errors.hpp to BUILT_SOURCES list and put it in conditional check 2944e5f521aSMarri Devender Rao GEN_ERRORS so that the elog-errors.hpp is generated only during local 2954e5f521aSMarri Devender Rao repository build. 2964e5f521aSMarri Devender Rao``` 2974e5f521aSMarri Devender Rao if GEN_ERRORS 2984e5f521aSMarri Devender Rao nobase_nodist_include_HEADERS += \ 2994e5f521aSMarri Devender Rao phosphor-logging/elog-errors.hpp 3004e5f521aSMarri Devender Rao endif 3014e5f521aSMarri Devender Rao if GEN_ERRORS 3024e5f521aSMarri Devender Rao BUILT_SOURCES += phosphor-logging/elog-errors.hpp 3034e5f521aSMarri Devender Rao endif 3044e5f521aSMarri Devender Rao``` 3059067c077SDeepak Kodihalli 3069067c077SDeepak Kodihalli###### Conditional check for native build 3074e5f521aSMarri Devender Rao * As the same Makefile is used both for recipe image build and native recipe 3084e5f521aSMarri Devender Rao build, add a conditional to ensure that only installation of error yaml files 3094e5f521aSMarri Devender Rao happens during native build. It is not required to build repository during 3104e5f521aSMarri Devender Rao native build. 3114e5f521aSMarri Devender Rao``` 3124e5f521aSMarri Devender Rao if !INSTALL_ERROR_YAML 3134e5f521aSMarri Devender Rao endif 3144e5f521aSMarri Devender Rao``` 3159067c077SDeepak Kodihalli 3169067c077SDeepak Kodihalli#### Autotools changes 3174e5f521aSMarri Devender Rao**Reference** 3184e5f521aSMarri Devender Rao * https://github.com/openbmc/openpower-debug-collector/blob/master/configure.ac 3197aafb12eSNagaraju Goruganti 3209067c077SDeepak Kodihalli###### Add option(argument) to enable/disable installing error yaml file 3214e5f521aSMarri Devender Rao * Install error yaml option(argument) is enabled for native recipe build 3224e5f521aSMarri Devender Rao and disabled for bitbake build. 3234e5f521aSMarri Devender Rao 3244e5f521aSMarri Devender Rao * When install error yaml option is disabled do not check for target specific 3254e5f521aSMarri Devender Rao packages in autotools configure script. 3264e5f521aSMarri Devender Rao 3279067c077SDeepak Kodihalli###### Add option(argument) to install error yaml files 3284e5f521aSMarri Devender Rao``` 3294e5f521aSMarri Devender RaoAC_ARG_ENABLE([install_error_yaml], 3304e5f521aSMarri Devender Rao AS_HELP_STRING([--enable-install_error_yaml], 3314e5f521aSMarri Devender Rao [Enable installing error yaml file]),[], [install_error_yaml=no]) 3324e5f521aSMarri Devender RaoAM_CONDITIONAL([INSTALL_ERROR_YAML], 3334e5f521aSMarri Devender Rao [test "x$enable_install_error_yaml" = "xyes"]) 3344e5f521aSMarri Devender RaoAS_IF([test "x$enable_install_error_yaml" != "xyes"], [ 3354e5f521aSMarri Devender Rao.. 3364e5f521aSMarri Devender Rao.. 3374e5f521aSMarri Devender Rao]) 3384e5f521aSMarri Devender Rao``` 3399067c077SDeepak Kodihalli 3409067c077SDeepak Kodihalli###### Add option(argument) to enable/disable generating elog-errors header file 3414e5f521aSMarri Devender Rao``` 3424e5f521aSMarri Devender RaoAC_ARG_ENABLE([gen_errors], 3434e5f521aSMarri Devender Rao AS_HELP_STRING([--enable-gen_errors], [Enable elog-errors.hpp generation ]), 3444e5f521aSMarri Devender Rao [],[gen_errors=yes]) 3454e5f521aSMarri Devender RaoAM_CONDITIONAL([GEN_ERRORS], [test "x$enable_gen_errors" != "xno"]) 3464e5f521aSMarri Devender Rao``` 3474e5f521aSMarri Devender Rao 3489067c077SDeepak Kodihalli#### Recipe changes 3494e5f521aSMarri Devender Rao**Reference** 3504e5f521aSMarri Devender Rao* https://github.com/openbmc/openbmc/blob/master/meta-openbmc-machines\ 3514e5f521aSMarri Devender Rao/meta-openpower/common/recipes-phosphor/debug/openpower-debug-collector.bb 3524e5f521aSMarri Devender Rao 3539067c077SDeepak Kodihalli###### Extend recipe for native and nativesdk 3544e5f521aSMarri Devender Rao* Extend the recipe for native and native SDK builds 3554e5f521aSMarri Devender Rao``` 3564e5f521aSMarri Devender RaoBBCLASSEXTEND += "native nativesdk" 3574e5f521aSMarri Devender Rao``` 3589067c077SDeepak Kodihalli###### Remove dependencies for native and native SDK build 3594e5f521aSMarri Devender Rao* Native recipe caters only for copying error yaml files to shared location. 3604e5f521aSMarri Devender Rao* For native and native SDK build remove dependency on packages that recipe 3614e5f521aSMarri Devender Rao build depends 3624e5f521aSMarri Devender Rao 3639067c077SDeepak Kodihalli###### Remove dependency on phosphor-logging for native build 3644e5f521aSMarri Devender Rao``` 3654e5f521aSMarri Devender RaoDEPENDS_remove_class-native = "phosphor-logging" 3664e5f521aSMarri Devender Rao``` 3679067c077SDeepak Kodihalli 3689067c077SDeepak Kodihalli###### Remove dependency on phosphor-logging for native SDK build 3694e5f521aSMarri Devender Rao``` 3704e5f521aSMarri Devender RaoDEPENDS_remove_class-nativesdk = "phosphor-logging" 3714e5f521aSMarri Devender Rao``` 3729067c077SDeepak Kodihalli 3739067c077SDeepak Kodihalli###### Add install_error_yaml argument during native build 3744e5f521aSMarri Devender Rao* Add package config to enable/disable install_error_yaml feature. 3759067c077SDeepak Kodihalli 3769067c077SDeepak Kodihalli###### Add package config to enable/disable install_error_yaml feature 3774e5f521aSMarri Devender Rao``` 3784e5f521aSMarri Devender RaoPACKAGECONFIG ??= "install_error_yaml" 3794e5f521aSMarri Devender RaoPACKAGECONFIG[install_error_yaml] = " \ 3804e5f521aSMarri Devender Rao --enable-install_error_yaml, \ 3814e5f521aSMarri Devender Rao --disable-install_error_yaml, ,\ 3824e5f521aSMarri Devender Rao " 3834e5f521aSMarri Devender Rao``` 3849067c077SDeepak Kodihalli###### Enable install_error_yaml check for native build 3854e5f521aSMarri Devender Rao``` 3864e5f521aSMarri Devender RaoPACKAGECONFIG_add_class-native = "install_error_yaml" 3874e5f521aSMarri Devender RaoPACKAGECONFIG_add_class-nativesdk = "install_error_yaml" 3884e5f521aSMarri Devender Rao``` 3899067c077SDeepak Kodihalli###### Disable install_error_yaml during target build 3904e5f521aSMarri Devender Rao``` 3914e5f521aSMarri Devender RaoPACKAGECONFIG_remove_class-target = "install_error_yaml" 3924e5f521aSMarri Devender Rao``` 3934e5f521aSMarri Devender Rao 3949067c077SDeepak Kodihalli###### Disable generating elog-errors.hpp for bitbake build 3954e5f521aSMarri Devender Rao* Disable gen_errors argument for bitbake image build as the application uses 3964e5f521aSMarri Devender Rao the elog-errors.hpp generated by phosphor-logging 3974e5f521aSMarri Devender Rao* Argument is enabled by default for local repository build in the configure 3984e5f521aSMarri Devender Rao script of the local repository. 3994e5f521aSMarri Devender Rao``` 4004e5f521aSMarri Devender Rao XTRA_OECONF += "--disable-gen_errors" 4014e5f521aSMarri Devender Rao``` 4024e5f521aSMarri Devender Rao 4039067c077SDeepak Kodihalli#### Local build 4044e5f521aSMarri Devender Rao* During local build use --prefix=/usr for the configure script. 4054e5f521aSMarri Devender Rao 4063210a9f3SMatt Spinler**Reference** 4073210a9f3SMatt Spinler* https://github.com/openbmc/openpower-debug-collector/blob/master/README.md 4083210a9f3SMatt Spinler 40999c2b405SMatt Spinler## Event Log Extensions 41099c2b405SMatt Spinler 41199c2b405SMatt SpinlerThe extension concept is a way to allow code that creates other formats of 41299c2b405SMatt Spinlererror logs besides phosphor-logging's event logs to still reside in the 41399c2b405SMatt Spinlerphosphor-log-manager application. 41499c2b405SMatt Spinler 41599c2b405SMatt SpinlerThe extension code lives in the `extensions/<extension>` subdirectories, 41699c2b405SMatt Spinlerand is enabled with a `--enable-<extension>` configure flag. The 41799c2b405SMatt Spinlerextension code won't compile unless enabled with this flag. 41899c2b405SMatt Spinler 41999c2b405SMatt SpinlerExtensions can register themselves to have functions called at the following 42099c2b405SMatt Spinlerpoints using the REGISTER_EXTENSION_FUNCTION macro. 42199c2b405SMatt Spinler* On startup 42299c2b405SMatt Spinler * Function type void(internal::Manager&) 42399c2b405SMatt Spinler* After an event log is created 42499c2b405SMatt Spinler * Function type void(args) 42599c2b405SMatt Spinler * The args are: 42699c2b405SMatt Spinler * const std::string& - The Message property 42799c2b405SMatt Spinler * uin32_t - The event log ID 42899c2b405SMatt Spinler * uint64_t - The event log timestamp 42999c2b405SMatt Spinler * Level - The event level 43099c2b405SMatt Spinler * const AdditionalDataArg& - the additional data 43199c2b405SMatt Spinler * const AssociationEndpointsArg& - Association endpoints (callouts) 43299c2b405SMatt Spinler* Before an event log is deleted, to check if it is allowed. 43399c2b405SMatt Spinler * Function type void(std::uint32_t, bool&) that takes the event ID 43499c2b405SMatt Spinler* After an event log is deleted 43599c2b405SMatt Spinler * Function type void(std::uint32_t) that takes the event ID 43699c2b405SMatt Spinler 43799c2b405SMatt SpinlerUsing these callback points, they can create their own event log for each 43899c2b405SMatt SpinlerOpenBMC event log that is created, and delete these logs when the corresponding 43999c2b405SMatt SpinlerOpenBMC event log is deleted. 44099c2b405SMatt Spinler 44199c2b405SMatt SpinlerIn addition, an extension has the option of disabling phosphor-logging's 44299c2b405SMatt Spinlerdefault error log capping policy so that it can use its own. The macro 44399c2b405SMatt SpinlerDISABLE_LOG_ENTRY_CAPS() is used for that. 44499c2b405SMatt Spinler 44599c2b405SMatt Spinler### Motivation 44699c2b405SMatt Spinler 44799c2b405SMatt SpinlerThe reason for adding support for extensions inside the phosphor-log-manager 44899c2b405SMatt Spinlerdaemon as opposed to just creating new daemons that listen for D-Bus signals is 44999c2b405SMatt Spinlerto allow interactions that would be complicated or expensive if just done over 45099c2b405SMatt SpinlerD-Bus, such as: 45199c2b405SMatt Spinler* Allowing for custom old log retention algorithms. 45299c2b405SMatt Spinler* Prohibiting manual deleting of certain logs based on an extension's 45399c2b405SMatt Spinler requirements. 45499c2b405SMatt Spinler 45599c2b405SMatt Spinler### Creating extensions 45699c2b405SMatt Spinler 45799c2b405SMatt Spinler1. Add a new flag to configure.ac to enable the extension: 45899c2b405SMatt Spinler``` 45999c2b405SMatt SpinlerAC_ARG_ENABLE([foo-extension], 46099c2b405SMatt Spinler AS_HELP_STRING([--enable-foo-extension], 46199c2b405SMatt Spinler [Create Foo logs])) 46299c2b405SMatt SpinlerAM_CONDITIONAL([ENABLE_FOO_EXTENSION], 46399c2b405SMatt Spinler [test "x$enable_foo_extension" == "xyes"]) 46499c2b405SMatt Spinler``` 46599c2b405SMatt Spinler2. Add the code in `extensions/<extension>/`. 46699c2b405SMatt Spinler3. Create a makefile include to add the new code to phosphor-log-manager: 46799c2b405SMatt Spinler``` 46899c2b405SMatt Spinlerphosphor_log_manager_SOURCES += \ 46999c2b405SMatt Spinler extensions/foo/foo.cpp 47099c2b405SMatt Spinler``` 4715cabd090SAndrew Geissler4. In `extensions/extensions.mk`, add the makefile include: 47299c2b405SMatt Spinler``` 47399c2b405SMatt Spinlerif ENABLE_FOO_EXTENSION 47499c2b405SMatt Spinlerinclude extensions/foo/foo.mk 47599c2b405SMatt Spinlerendif 47699c2b405SMatt Spinler``` 4775cabd090SAndrew Geissler5. In the extension code, register the functions to call and optionally disable 47899c2b405SMatt Spinler log capping using the provided macros: 47999c2b405SMatt Spinler``` 48099c2b405SMatt SpinlerDISABLE_LOG_ENTRY_CAPS(); 48199c2b405SMatt Spinler 48299c2b405SMatt Spinlervoid fooStartup(internal::Manager& manager) 48399c2b405SMatt Spinler{ 48499c2b405SMatt Spinler // Initialize 48599c2b405SMatt Spinler} 48699c2b405SMatt Spinler 48799c2b405SMatt SpinlerREGISTER_EXTENSION_FUNCTION(fooStartup); 48899c2b405SMatt Spinler 48999c2b405SMatt Spinlervoid fooCreate(const std::string& message, uint32_t id, uint64_t timestamp, 49099c2b405SMatt Spinler Entry::Level severity, const AdditionalDataArg& additionalData, 49199c2b405SMatt Spinler const AssociationEndpointsArg& assocs) 49299c2b405SMatt Spinler{ 49399c2b405SMatt Spinler // Create a different type of error log based on 'entry'. 49499c2b405SMatt Spinler} 49599c2b405SMatt Spinler 49699c2b405SMatt SpinlerREGISTER_EXTENSION_FUNCTION(fooCreate); 49799c2b405SMatt Spinler 49899c2b405SMatt Spinlervoid fooRemove(uint32_t id) 49999c2b405SMatt Spinler{ 50099c2b405SMatt Spinler // Delete the extension error log that corresponds to 'id'. 50199c2b405SMatt Spinler} 50299c2b405SMatt Spinler 50399c2b405SMatt SpinlerREGISTER_EXTENSION_FUNCTION(fooRemove); 50499c2b405SMatt Spinler``` 5053210a9f3SMatt Spinler### Extension List 50699c2b405SMatt Spinler 5073210a9f3SMatt SpinlerThe supported extensions are: 5083210a9f3SMatt Spinler 5093210a9f3SMatt Spinler* OpenPower PELs 5103210a9f3SMatt Spinler * Enabled with --enable-openpower-pel-extension 5113210a9f3SMatt Spinler * Detailed information can be found 5123210a9f3SMatt Spinler [here](extensions/openpower-pels/README.md) 5130649b985SAndrew Geissler 51424eb160fSJeremy Kerr## Remote Logging via Rsyslog 51524eb160fSJeremy KerrThe BMC has the ability to stream out local logs (that go to the systemd journal) 51624eb160fSJeremy Kerrvia rsyslog (https://www.rsyslog.com/). 51724eb160fSJeremy Kerr 51824eb160fSJeremy KerrThe BMC will send everything. Any kind of filtering and appropriate storage 51924eb160fSJeremy Kerrwill have to be managed on the rsyslog server. Various examples are available 52024eb160fSJeremy Kerron the internet. Here are few pointers : 52124eb160fSJeremy Kerrhttps://www.rsyslog.com/storing-and-forwarding-remote-messages/ 52224eb160fSJeremy Kerrhttps://www.rsyslog.com/doc/rsyslog%255Fconf%255Ffilter.html 52324eb160fSJeremy Kerrhttps://www.thegeekdiary.com/understanding-rsyslog-filter-options/ 52424eb160fSJeremy Kerr 52524eb160fSJeremy Kerr#### Configuring rsyslog server for remote logging 52624eb160fSJeremy KerrThe BMC is an rsyslog client. To stream out logs, it needs to talk to an rsyslog 52724eb160fSJeremy Kerrserver, to which there's connectivity over a network. REST API can be used to 52824eb160fSJeremy Kerrset the remote server's IP address and port number. 52924eb160fSJeremy Kerr 53024eb160fSJeremy KerrThe following presumes a user has logged on to the BMC (see 53124eb160fSJeremy Kerrhttps://github.com/openbmc/docs/blob/master/rest-api.md). 53224eb160fSJeremy Kerr 53324eb160fSJeremy KerrSet the IP: 53424eb160fSJeremy Kerr``` 53524eb160fSJeremy Kerrcurl -b cjar -k -H "Content-Type: application/json" -X PUT \ 53624eb160fSJeremy Kerr -d '{"data": <IP address>}' \ 53724eb160fSJeremy Kerr https://<BMC IP address>/xyz/openbmc_project/logging/config/remote/attr/Address 53824eb160fSJeremy Kerr``` 53924eb160fSJeremy Kerr 54024eb160fSJeremy KerrSet the port: 54124eb160fSJeremy Kerr``` 54224eb160fSJeremy Kerrcurl -b cjar -k -H "Content-Type: application/json" -X PUT \ 54324eb160fSJeremy Kerr -d '{"data": <port number>}' \ 54424eb160fSJeremy Kerr https://<BMC IP address>/xyz/openbmc_project/logging/config/remote/attr/Port 54524eb160fSJeremy Kerr``` 54624eb160fSJeremy Kerr 54724eb160fSJeremy Kerr#### Querying the current configuration 54824eb160fSJeremy Kerr``` 54924eb160fSJeremy Kerrcurl -b cjar -k \ 55024eb160fSJeremy Kerr https://<BMC IP address>/xyz/openbmc_project/logging/config/remote 55124eb160fSJeremy Kerr``` 55224eb160fSJeremy Kerr 55324eb160fSJeremy Kerr#### Setting the hostname 55424eb160fSJeremy KerrRsyslog can store logs separately for each host. For this reason, it's useful to 55524eb160fSJeremy Kerrprovide a unique hostname to each managed BMC. Here's how that can be done via a 55624eb160fSJeremy KerrREST API : 55724eb160fSJeremy Kerr``` 55824eb160fSJeremy Kerrcurl -b cjar -k -H "Content-Type: application/json" -X PUT \ 55924eb160fSJeremy Kerr -d '{"data": "myHostName"}' \ 56024eb160fSJeremy Kerr https://<BMC IP address>//xyz/openbmc_project/network/config/attr/HostName 56124eb160fSJeremy Kerr``` 56224eb160fSJeremy Kerr 56324eb160fSJeremy Kerr#### Disabling remote logging 56424eb160fSJeremy KerrRemote logging can be disabled by writing 0 to the port, or an empty string("") 56524eb160fSJeremy Kerrto the IP. 56624eb160fSJeremy Kerr 56724eb160fSJeremy Kerr#### Changing the rsyslog server 56824eb160fSJeremy KerrWhen switching to a new server from an existing one (i.e the address, or port, 56924eb160fSJeremy Kerror both change), it is recommended to disable the existing configuration first. 57024eb160fSJeremy Kerr 5710649b985SAndrew Geissler## Boot Fail on Hardware Errors 5720649b985SAndrew Geissler 5730649b985SAndrew Geisslerphosphor-logging supports a setting, which when set, will result in the 5740649b985SAndrew Geisslersoftware looking at new phosphor-logging entries being created, and if a 5750649b985SAndrew GeisslerCALLOUT* is found within the entry, ensuring the system will not power 5760649b985SAndrew Geissleron. 5770649b985SAndrew Geissler 5780649b985SAndrew GeisslerThe full design for this can be found 5790649b985SAndrew Geissler[here](https://github.com/openbmc/docs/blob/master/designs/fail-boot-on-hw-error.md) 5800649b985SAndrew Geissler 5810649b985SAndrew GeisslerTo enable this function: 5820649b985SAndrew Geissler 5830649b985SAndrew Geissler``` 5840649b985SAndrew Geisslerbusctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/logging/settings xyz.openbmc_project.Logging.Settings QuiesceOnHwError b true 5850649b985SAndrew Geissler``` 5860649b985SAndrew Geissler 5870649b985SAndrew GeisslerTo check if an entry is blocking the boot: 5880649b985SAndrew Geissler``` 5890649b985SAndrew Geisslerobmcutil listbootblock 5900649b985SAndrew Geissler``` 5910649b985SAndrew Geissler 5920649b985SAndrew GeisslerResolve or clear the corresponding entry to allow the system to boot. 593