mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-27 17:43:41 +01:00
61be51e56b
To make the markup package easier to maintain: 1. Split some go files into small files 2. Use a shared util.NopCloser, remove duplicate code 3. Remove unused functions
36 lines
754 B
Go
36 lines
754 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package log
|
|
|
|
import (
|
|
"os"
|
|
|
|
"code.gitea.io/gitea/modules/util"
|
|
)
|
|
|
|
type WriterConsoleOption struct {
|
|
Stderr bool
|
|
}
|
|
|
|
type eventWriterConsole struct {
|
|
*EventWriterBaseImpl
|
|
}
|
|
|
|
var _ EventWriter = (*eventWriterConsole)(nil)
|
|
|
|
func NewEventWriterConsole(name string, mode WriterMode) EventWriter {
|
|
w := &eventWriterConsole{EventWriterBaseImpl: NewEventWriterBase(name, "console", mode)}
|
|
opt := mode.WriterOption.(WriterConsoleOption)
|
|
if opt.Stderr {
|
|
w.OutputWriteCloser = util.NopCloser{Writer: os.Stderr}
|
|
} else {
|
|
w.OutputWriteCloser = util.NopCloser{Writer: os.Stdout}
|
|
}
|
|
return w
|
|
}
|
|
|
|
func init() {
|
|
RegisterEventWriter("console", NewEventWriterConsole)
|
|
}
|