mirror of
https://github.com/go-gitea/gitea
synced 2024-11-05 09:44:26 +00:00
49cab2b01f
* logs: add the buffer logger to inspect logs during testing Signed-off-by: Loïc Dachary <loic@dachary.org> * migrations: add test for importing pull requests in gitea uploader Signed-off-by: Loïc Dachary <loic@dachary.org> * for each git.OpenRepositoryCtx, call Close * Content is expected to return the content of the log * test for errors before defer Co-authored-by: Loïc Dachary <loic@dachary.org> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
28 lines
732 B
Go
28 lines
732 B
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package log
|
|
|
|
// LoggerProvider represents behaviors of a logger provider.
|
|
type LoggerProvider interface {
|
|
Init(config string) error
|
|
Content() (string, error)
|
|
EventLogger
|
|
}
|
|
|
|
type loggerProvider func() LoggerProvider
|
|
|
|
var providers = make(map[string]loggerProvider)
|
|
|
|
// Register registers given logger provider to providers.
|
|
func Register(name string, log loggerProvider) {
|
|
if log == nil {
|
|
panic("log: register provider is nil")
|
|
}
|
|
if _, dup := providers[name]; dup {
|
|
panic("log: register called twice for provider \"" + name + "\"")
|
|
}
|
|
providers[name] = log
|
|
}
|