newFormatterJSON creates a new formatterJSON instance.
(groups []attrGroup, buf *buffer, gcpStyle bool)
| 27 | |
| 28 | // newFormatterJSON creates a new formatterJSON instance. |
| 29 | func newFormatterJSON(groups []attrGroup, buf *buffer, gcpStyle bool) *formatterJSON { |
| 30 | f := &formatterJSON{ |
| 31 | formatterCommon: newFormatterCommon(groups, buf), |
| 32 | } |
| 33 | |
| 34 | // Set the level and message keys based on the style. |
| 35 | if gcpStyle { |
| 36 | f.levelKey = "severity" |
| 37 | f.messageKey = "message" |
| 38 | } else { |
| 39 | f.levelKey = slog.LevelKey |
| 40 | f.messageKey = slog.MessageKey |
| 41 | } |
| 42 | |
| 43 | return f |
| 44 | } |
| 45 | |
| 46 | // format formats a log record. |
| 47 | func (s *formatterJSON) format(r slog.Record) { |
no test coverage detected