Skip to content

Commit 284b397

Browse files
committed
static setmessageoption
1 parent 8b43d26 commit 284b397

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/InfoLogger.cxx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class InfoLogger::Impl {
228228
int logV(InfoLogger::Severity severity, const char *message, va_list ap) __attribute__((format(printf, 3, 0)));
229229

230230

231-
// extended log function, with all extra fields, including a specific context
231+
/// extended log function, with all extra fields, including a specific context
232232
/// \return 0 on success, an error code otherwise (but never throw exceptions)..
233233
int logV(const InfoLoggerMessageOption &options, const InfoLoggerContext& context, const char *message, va_list ap) __attribute__((format(printf, 4,0)));
234234

@@ -570,7 +570,7 @@ InfoLogger &InfoLogger::operator<<(const InfoLogger::InfoLoggerMessageOption opt
570570
}
571571

572572

573-
InfoLogger::Severity getSeverityFromString(const char *txt) {
573+
InfoLogger::Severity InfoLogger::getSeverityFromString(const char *txt) {
574574
// permissive implementation
575575
switch (tolower(txt[0])) {
576576
case 'i':
@@ -606,6 +606,23 @@ InfoLogger::Severity getSeverityFromString(const char *txt) {
606606
}
607607

608608

609+
int InfoLogger::setMessageOption(const char *fieldName, const char *fieldValue, InfoLoggerMessageOption &output) {
610+
if (!strcmp(fieldName,"Severity")) {
611+
output.severity=getSeverityFromString(fieldValue);
612+
} else if (!strcmp(fieldName,"Level")) {
613+
output.level=atoi(fieldValue);
614+
} else if (!strcmp(fieldName,"ErrorCode")) {
615+
output.errorCode=atoi(fieldValue);
616+
} else if (!strcmp(fieldName,"SourceFile")) {
617+
output.sourceFile=fieldValue;
618+
} else if (!strcmp(fieldName,"SourceLine")) {
619+
output.sourceLine=atoi(fieldValue);
620+
} else {
621+
return -1;
622+
}
623+
return 0;
624+
}
625+
609626

610627
// end of namespace
611628
}

0 commit comments

Comments
 (0)