1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /*
- * @Author: lwnmengjing
- * @Date: 2021/6/10 10:26 上午
- * @Last Modified by: lwnmengjing
- * @Last Modified time: 2021/6/10 10:26 上午
- */
- package logger
- type Option func(*options)
- type options struct {
- driver string
- path string
- level string
- stdout string
- maxDays int
- cap uint
- }
- func setDefault() options {
- return options{
- driver: "default",
- path: "temp/logs",
- level: "warn",
- stdout: "default",
- maxDays: 7,
- }
- }
- func WithType(s string) Option {
- return func(o *options) {
- o.driver = s
- }
- }
- func WithPath(s string) Option {
- return func(o *options) {
- o.path = s
- }
- }
- func WithLevel(s string) Option {
- return func(o *options) {
- o.level = s
- }
- }
- func WithStdout(s string) Option {
- return func(o *options) {
- o.stdout = s
- }
- }
- func WithCap(n uint) Option {
- return func(o *options) {
- o.cap = n
- }
- }
- func WithMaxDays(n int) Option {
- return func(o *options) {
- o.maxDays = n
- }
- }
|