add support for --since in journalctl DSN (#917)

This commit is contained in:
blotus 2021-08-31 12:40:22 +02:00 committed by GitHub
parent ff0fb50032
commit b5d0d56a11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -215,6 +215,8 @@ func (j *JournalCtlSource) ConfigureByDSN(dsn string, labelType string, logger *
return errors.Wrapf(err, "unknown level %s", value[0])
}
j.logger.Logger.SetLevel(lvl)
case "since":
j.args = append(j.args, "--since", value[0])
default:
return fmt.Errorf("unsupported key %s in journalctl DSN", key)
}

View file

@ -82,6 +82,10 @@ func TestConfigureDSN(t *testing.T) {
dsn: "journalctl://filters=_UID=1000&log_level=foobar",
expectedErr: "unknown level foobar: not a valid logrus Level:",
},
{
dsn: "journalctl://filters=_UID=1000&log_level=warn&since=yesterday",
expectedErr: "",
},
}
subLogger := log.WithFields(log.Fields{
"type": "journalctl",