* Parses a GVariant object containing a Log signal. The input * GVariant needs to be of 'a{sv}' which is a named dictionary. It * must contain the following key values to be valid: * * - (u) log_group Translated into LogGroup * - (u) log_category Translated into LogCategory * - (s) log_session_token An optional session token string * - (s) log_message
| 295 | * @return Events::Log object of the parsed GVariant object |
| 296 | */ |
| 297 | Log parse_dict(GVariant *logevent) |
| 298 | { |
| 299 | auto group = glib2::Value::Dict::Lookup<LogGroup>(logevent, "log_group"); |
| 300 | auto category = glib2::Value::Dict::Lookup<LogCategory>(logevent, "log_category"); |
| 301 | auto message = glib2::Value::Dict::Lookup<std::string>(logevent, |
| 302 | "log_message"); |
| 303 | try |
| 304 | { |
| 305 | auto session_token = glib2::Value::Dict::Lookup<std::string>(logevent, |
| 306 | "log_session_token"); |
| 307 | return Log(group, category, session_token, message); |
| 308 | } |
| 309 | catch (const glib2::Utils::Exception &) |
| 310 | { |
| 311 | // This is fine; the log_session_token may not be available |
| 312 | // and then we treat this event as a "normal" LogEvent without |
| 313 | // the sessoin token value |
| 314 | } |
| 315 | return Log(group, category, message, false); |
| 316 | } |
| 317 | |
| 318 | |
| 319 | /** |