Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-datastore
Commits
889bfe61
Commit
889bfe61
authored
Jun 16, 2017
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log more in LogDatastore
parent
e7613971
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
basic_ds.go
basic_ds.go
+40
-1
No files found.
basic_ds.go
View file @
889bfe61
...
...
@@ -169,17 +169,56 @@ func (d *LogDatastore) Delete(key Key) (err error) {
// Query implements Datastore.Query
func
(
d
*
LogDatastore
)
Query
(
q
dsq
.
Query
)
(
dsq
.
Results
,
error
)
{
log
.
Printf
(
"%s: Query
\n
"
,
d
.
Name
)
log
.
Printf
(
"%s: q.Prefix: %s
\n
"
,
d
.
Name
,
q
.
Prefix
)
log
.
Printf
(
"%s: q.KeysOnly: %s
\n
"
,
d
.
Name
,
q
.
KeysOnly
)
log
.
Printf
(
"%s: q.Filters: %d
\n
"
,
d
.
Name
,
len
(
q
.
Filters
))
log
.
Printf
(
"%s: q.Orders: %d
\n
"
,
d
.
Name
,
len
(
q
.
Orders
))
log
.
Printf
(
"%s: q.Offset: %d
\n
"
,
d
.
Name
,
q
.
Offset
)
return
d
.
child
.
Query
(
q
)
}
// LogBatch logs all accesses through the batch.
type
LogBatch
struct
{
Name
string
child
Batch
}
func
(
d
*
LogDatastore
)
Batch
()
(
Batch
,
error
)
{
log
.
Printf
(
"%s: Batch
\n
"
,
d
.
Name
)
if
bds
,
ok
:=
d
.
child
.
(
Batching
);
ok
{
return
bds
.
Batch
()
b
,
err
:=
bds
.
Batch
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
LogBatch
{
Name
:
d
.
Name
,
child
:
b
,
},
nil
}
return
nil
,
ErrBatchUnsupported
}
// Put implements Batch.Put
func
(
d
*
LogBatch
)
Put
(
key
Key
,
value
interface
{})
(
err
error
)
{
log
.
Printf
(
"%s: BatchPut %s
\n
"
,
d
.
Name
,
key
)
// log.Printf("%s: Put %s ```%s```", d.Name, key, value)
return
d
.
child
.
Put
(
key
,
value
)
}
// Delete implements Batch.Delete
func
(
d
*
LogBatch
)
Delete
(
key
Key
)
(
err
error
)
{
log
.
Printf
(
"%s: BatchDelete %s
\n
"
,
d
.
Name
,
key
)
return
d
.
child
.
Delete
(
key
)
}
// Commit implements Batch.Commit
func
(
d
*
LogBatch
)
Commit
()
(
err
error
)
{
log
.
Printf
(
"%s: BatchCommit
\n
"
,
d
.
Name
)
return
d
.
child
.
Commit
()
}
func
(
d
*
LogDatastore
)
Close
()
error
{
log
.
Printf
(
"%s: Close
\n
"
,
d
.
Name
)
if
cds
,
ok
:=
d
.
child
.
(
io
.
Closer
);
ok
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment