github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/log/provider.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package log 7 8 // LoggerProvider represents behaviors of a logger provider. 9 type LoggerProvider interface { 10 Init(config string) error 11 Content() (string, error) 12 EventLogger 13 } 14 15 type loggerProvider func() LoggerProvider 16 17 var providers = make(map[string]loggerProvider) 18 19 // Register registers given logger provider to providers. 20 func Register(name string, log loggerProvider) { 21 if log == nil { 22 panic("log: register provider is nil") 23 } 24 if _, dup := providers[name]; dup { 25 panic("log: register called twice for provider \"" + name + "\"") 26 } 27 providers[name] = log 28 }