-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample_rest_test.go
More file actions
29 lines (22 loc) · 943 Bytes
/
example_rest_test.go
File metadata and controls
29 lines (22 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) 2014 Datacratic. All rights reserved.
package klog_test
import (
"github.com/datacratic/goklog/klog"
)
// The klogr package provides wrapppers for printer stages which makes them
// accessible from a rest interface using the gorest package.
func Example_REST() {
// Here we create a REST enabled filter which allows us to modify the
// filtering rules of the stage while the program is running.
filter := klog.NewFilterREST("/path/to/filter", klog.FilterIn)
// The ring stage prints to a ring buffer containing the last N elements
// printed. Wrapping this stage in a REST interface allows us to query the
// most recent log elements remotely.
ring := klog.NewRingREST("/path/to/ring", 1000)
// REST enabled stages act like regular stages so they can be used directly
// in a klog pipeline.
klog.SetPrinter(
klog.Chain(filter,
klog.Fork(ring, klog.GetPrinter())))
klog.KPrint("a.b.c", "hello world")
}