ConfigureDefaultFormat will set the default format to "console" if the writer is a terminal. If already configured, it passes through the writer so a deeply nested encoder can configure its own default format.
(wo caddy.WriterOpener)
| 100 | // through the writer so a deeply nested encoder can configure |
| 101 | // its own default format. |
| 102 | func (fe *AppendEncoder) ConfigureDefaultFormat(wo caddy.WriterOpener) error { |
| 103 | if !fe.wrappedIsDefault { |
| 104 | if cfd, ok := fe.wrapped.(caddy.ConfiguresFormatterDefault); ok { |
| 105 | return cfd.ConfigureDefaultFormat(wo) |
| 106 | } |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | if caddy.IsWriterStandardStream(wo) && term.IsTerminal(int(os.Stderr.Fd())) { |
| 111 | fe.wrapped = &ConsoleEncoder{} |
| 112 | if p, ok := fe.wrapped.(caddy.Provisioner); ok { |
| 113 | if err := p.Provision(fe.ctx); err != nil { |
| 114 | return fmt.Errorf("provisioning fallback encoder module: %v", err) |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | // UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax: |
| 122 | // |
nothing calls this directly
no test coverage detected