(config outputs.Config)
| 52 | } |
| 53 | |
| 54 | func initConsole(config outputs.Config) (outputs.OutputGroup, error) { |
| 55 | stdout := os.Stdout |
| 56 | cfg, ok := config.Output.(Config) |
| 57 | if !ok { |
| 58 | return outputs.Fail(outputs.ErrInvalidConfig(outputs.Console, config.Output)) |
| 59 | } |
| 60 | tmpl := cfg.Template |
| 61 | if tmpl == "" { |
| 62 | tmpl = template |
| 63 | } |
| 64 | |
| 65 | formatter, err := event.NewFormatter(tmpl) |
| 66 | if err != nil { |
| 67 | return outputs.Fail(err) |
| 68 | } |
| 69 | |
| 70 | if cfg.ParamKVDelimiter != "" { |
| 71 | event.ParamKVDelimiter = cfg.ParamKVDelimiter |
| 72 | } |
| 73 | |
| 74 | c := &console{ |
| 75 | writer: bufio.NewWriterSize(stdout, 8*1024), |
| 76 | formatter: formatter, |
| 77 | format: format(cfg.Format), |
| 78 | } |
| 79 | |
| 80 | if cfg.Colorize { |
| 81 | c.colorFormatter = event.NewColorFormatter(formatter) |
| 82 | } |
| 83 | |
| 84 | return outputs.Success(c), nil |
| 85 | } |
| 86 | |
| 87 | func (c *console) Close() error { return c.writer.Flush() } |
| 88 | func (c *console) Connect() error { return nil } |
nothing calls this directly
no test coverage detected