Show last log if no ID specified
This commit is contained in:
parent
22a8e32e2c
commit
992c41c84b
@ -22,6 +22,9 @@
|
|||||||
- Flag `--disable-preload` to ignore `[[preload]]` section of
|
- Flag `--disable-preload` to ignore `[[preload]]` section of
|
||||||
configuration file.
|
configuration file.
|
||||||
|
|
||||||
|
- Now `out-of-tree log dump` will show the last log if no ID
|
||||||
|
specified.
|
||||||
|
|
||||||
## [1.3.0] 2020-05-30
|
## [1.3.0] 2020-05-30
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
18
db.go
18
db.go
@ -254,6 +254,24 @@ func getLogByID(db *sql.DB, id int) (le logEntry, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLastLog(db *sql.DB) (le logEntry, err error) {
|
||||||
|
err = db.QueryRow("SELECT MAX(id), time, name, type, tag, "+
|
||||||
|
"distro_type, distro_release, kernel_release, "+
|
||||||
|
"build_ok, run_ok, test_ok, "+
|
||||||
|
"build_output, run_output, test_output, "+
|
||||||
|
"qemu_stdout, qemu_stderr, "+
|
||||||
|
"kernel_panic, timeout_kill "+
|
||||||
|
"FROM log").Scan(&le.ID, &le.Timestamp,
|
||||||
|
&le.Name, &le.Type, &le.Tag,
|
||||||
|
&le.DistroType, &le.DistroRelease, &le.KernelRelease,
|
||||||
|
&le.Build.Ok, &le.Run.Ok, &le.Test.Ok,
|
||||||
|
&le.Build.Output, &le.Run.Output, &le.Test.Output,
|
||||||
|
&le.Stdout, &le.Stderr,
|
||||||
|
&le.KernelPanic, &le.KilledByTimeout,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func createSchema(db *sql.DB) (err error) {
|
func createSchema(db *sql.DB) (err error) {
|
||||||
err = createMetadataTable(db)
|
err = createMetadataTable(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
7
log.go
7
log.go
@ -100,7 +100,12 @@ func logHandler(db *sql.DB, path, tag string, num int, rate bool) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func logDumpHandler(db *sql.DB, id int) (err error) {
|
func logDumpHandler(db *sql.DB, id int) (err error) {
|
||||||
l, err := getLogByID(db, id)
|
var l logEntry
|
||||||
|
if id > 0 {
|
||||||
|
l, err = getLogByID(db, id)
|
||||||
|
} else {
|
||||||
|
l, err = getLastLog(db)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -217,7 +217,7 @@ func main() {
|
|||||||
|
|
||||||
logDumpCommand := logCommand.Command("dump",
|
logDumpCommand := logCommand.Command("dump",
|
||||||
"Show all info for log entry with ID")
|
"Show all info for log entry with ID")
|
||||||
logDumpID := logDumpCommand.Arg("ID", "").Required().Int()
|
logDumpID := logDumpCommand.Arg("ID", "").Default("-1").Int()
|
||||||
|
|
||||||
logJSONCommand := logCommand.Command("json", "Generate json statistics")
|
logJSONCommand := logCommand.Command("json", "Generate json statistics")
|
||||||
logJSONTag := logJSONCommand.Flag("tag", "Filter tag").Required().String()
|
logJSONTag := logJSONCommand.Flag("tag", "Filter tag").Required().String()
|
||||||
|
Loading…
Reference in New Issue
Block a user