Commit 1380e37e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6a52ac1a
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package main package main
import ( import (
_ "../../storage" // XXX rel ok? //_ "../../storage" // XXX rel ok?
neo "../.." neo "../.."
"fmt" "fmt"
"context" "context"
......
...@@ -30,6 +30,8 @@ import ( ...@@ -30,6 +30,8 @@ import (
"os" "os"
"../../../../storage/fs1" "../../../../storage/fs1"
"../../../../xcommon/xfmt"
) )
...@@ -86,6 +88,9 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) { ...@@ -86,6 +88,9 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
return fmt.Errorf("@%v: previous record could not be read", topPos) return fmt.Errorf("@%v: previous record could not be read", topPos)
} }
// buffer for formatting
xbuf := xfmt.Buffer{}
// now loop loading transactions backwards until EOF / ntxn limit // now loop loading transactions backwards until EOF / ntxn limit
for i := ntxn; i > 0; i-- { for i := ntxn; i > 0; i-- {
err = txnh.LoadPrev(fSeq, fs1.LoadAll) err = txnh.LoadPrev(fSeq, fs1.LoadAll)
...@@ -114,17 +119,30 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) { ...@@ -114,17 +119,30 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
} }
// print information about read txn record // print information about read txn record
_, err = fmt.Fprintf(w, "%s: hash=%x\nuser=%s description=%s length=%d offset=%d (+%d)\n\n", xbuf.Reset()
txnh.Tid.Time(), sha1.Sum(data), xbuf .S(txnh.Tid.Time()) .S("hash=") .X(sha1.Sum(data))
// fstail.py uses repr to print user/description: // fstail.py uses repr to print user/description:
// https://github.com/zopefoundation/ZODB/blob/5.2.0-4-g359f40ec7/src/ZODB/scripts/fstail.py#L39 // https://github.com/zopefoundation/ZODB/blob/5.2.0-4-g359f40ec7/src/ZODB/scripts/fstail.py#L39
pyQuoteBytes(txnh.User), pyQuoteBytes(txnh.Description), xbuf .S("\nuser=") .Qpyb(txnh.User) .S(" description=") .Qpyb(txnh.Description)
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length // NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
txnh.Len - 8, xbuf .S(" length=") .D(txnh.Len - 8)
xbuf .S(" offset=") .D(txnh.Pos) .S(" (+") .D(txnh.HeaderLen()) .S(")\n\n")
txnh.Pos, txnh.HeaderLen()) // // print information about read txn record
// _, err = fmt.Fprintf(w, "%s: hash=%x\nuser=%s description=%s length=%d offset=%d (+%d)\n\n",
// txnh.Tid.Time(), sha1.Sum(data),
//
// // fstail.py uses repr to print user/description:
// // https://github.com/zopefoundation/ZODB/blob/5.2.0-4-g359f40ec7/src/ZODB/scripts/fstail.py#L39
// pyQuoteBytes(txnh.User), pyQuoteBytes(txnh.Description),
//
// // NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
// txnh.Len - 8,
//
// txnh.Pos, txnh.HeaderLen())
_, err = w.Write(xbuf.Bytes())
if err != nil { if err != nil {
break break
} }
......
...@@ -80,3 +80,11 @@ func TestXFmt(t *testing.T) { ...@@ -80,3 +80,11 @@ func TestXFmt(t *testing.T) {
} }
} }
} }
func BenchmarkFmt(t *testing.T) {
// TODO
}
func BenchmarkXFmt(t *testing.T) {
// TODO
}
// XXX move me out of here package xmft
package main
import ( import (
"bytes" "bytes"
...@@ -83,3 +81,16 @@ func pyAppendQuoteBytes(buf, b []byte) []byte { ...@@ -83,3 +81,16 @@ func pyAppendQuoteBytes(buf, b []byte) []byte {
buf = append(buf, quote) buf = append(buf, quote)
return buf return buf
} }
// Qpy appends string quoted as Python would do
func (b *Buffer) Qpy(s string) *Buffer {
*b = ... // TODO
return b
}
// Qpyb appends []byte quoted as Python would do
func (b *Buffer) Qpyb(x []byte) *Buffer {
*b = ... // TODO
return b
}
// XXX move me to common place package xfmt
package main
import ( import (
"testing" "testing"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment