carb::crashreporter::addCrashMetadata

Defined in carb/crashreporter/CrashReporterUtils.h

template<>
inline bool carb::crashreporter::addCrashMetadata(const char *keyName, const char *value)

Adds a metadata value to the crash reporter.

Remark

This adds a new metadata value to the crash reporter. When a crash occurs, all values added through here will be collected and transmitted as metadata to accompany the crash report. The metadata value will value will be added (or updated) to the crash reporter by adding (or updating) a key under the “/crashreporter/data/” settings branch.

Note

This should not be called frequently to update the value of a piece of metadata. Doing so will be likely to incur a performance hit since the crash reporter watches for changes on the “/crashreporter/data/” settings branch that is modified here. Each time the branch changes, the crash reporter’s metadata list is updated. If possible, the value for any given piece of metadata should only be updated when it either changes or just set once on startup and left alone.

Template Parameters

T – The type of the value to set. This may be any value type that is compatible with std::to_string().

Parameters
  • keyName[in] The name of the metadata key to set. This must only contain printable ASCII characters except for a double quote (‘”’), slash (‘/’), or whitespace. It is the caller’s responsibility to ensure the key name will not be overwriting another system’s metadata value. One way to do this is to prefix the key name with the name of the extension or plugin (sanitized to follow the above formatting rules).

  • value[in] The value to add to the crash reporter’s metadata table. This may be any string that is accepted by carb::settings::ISettings::setString() as a new value. Note that this will remove the metadata value if it is set to nullptr or an empty string.

Returns

true if the new metadata value is successfully set. Returns false otherwise.