gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/debug/log/options.go (about) 1 package log 2 3 import "time" 4 5 // Option used by the logger 6 type Option func(*Options) 7 8 // Options are logger options 9 type Options struct { 10 // Size is the size of ring buffer 11 Size int 12 } 13 14 // Size sets the size of the ring buffer 15 func Size(s int) Option { 16 return func(o *Options) { 17 o.Size = s 18 } 19 } 20 21 // DefaultOptions returns default options 22 func DefaultOptions() Options { 23 return Options{ 24 Size: DefaultSize, 25 } 26 } 27 28 // ReadOptions for querying the logs 29 type ReadOptions struct { 30 // Since what time in past to return the logs 31 Since time.Time 32 // Count specifies number of logs to return 33 Count int 34 // Stream requests continuous log stream 35 Stream bool 36 } 37 38 // ReadOption used for reading the logs 39 type ReadOption func(*ReadOptions) 40 41 // Since sets the time since which to return the log records 42 func Since(s time.Time) ReadOption { 43 return func(o *ReadOptions) { 44 o.Since = s 45 } 46 } 47 48 // Count sets the number of log records to return 49 func Count(c int) ReadOption { 50 return func(o *ReadOptions) { 51 o.Count = c 52 } 53 } 54 55 // Stream requests continuous log stream 56 func Stream(s bool) ReadOption { 57 return func(o *ReadOptions) { 58 o.Stream = s 59 } 60 }