diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-27 19:53:43 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-27 19:55:37 +0900 |
| commit | 802e6afa34de7f6124157153b0bde4ac25d7b363 (patch) | |
| tree | 03e6b7601b182181a24285f0e0d68cf34329bac3 /container/msg.go | |
| parent | e906cae9ee0fd8b7b35c4a71af8ba86e60dd3c24 (diff) | |
container/output: move global output to msg
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/msg.go')
| -rw-r--r-- | container/msg.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/container/msg.go b/container/msg.go index 4be0fd2d..1512a583 100644 --- a/container/msg.go +++ b/container/msg.go @@ -50,3 +50,18 @@ func (msg *DefaultMsg) Verbosef(format string, v ...any) { func (msg *DefaultMsg) Suspend() { msg.inactive.Store(true) } func (msg *DefaultMsg) Resume() bool { return msg.inactive.CompareAndSwap(true, false) } func (msg *DefaultMsg) BeforeExit() {} + +// msg is the [Msg] implemented used by all exported [container] functions. +var msg Msg = new(DefaultMsg) + +// GetOutput returns the current active [Msg] implementation. +func GetOutput() Msg { return msg } + +// SetOutput replaces the current active [Msg] implementation. +func SetOutput(v Msg) { + if v == nil { + msg = new(DefaultMsg) + } else { + msg = v + } +} |
