diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a0cc8..5d6b3d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ The format is based on [Keep a Changelog], and this project adheres to [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html +## [0.4.1] - 2020-11-21 + +## Added + +- Add `DefaultPrinter`, the printer used by `Write()`, `Format()` and `Print()` + ## [0.4.0] - 2020-05-05 ## Added @@ -114,6 +120,7 @@ The format is based on [Keep a Changelog], and this project adheres to [0.3.4]: https://github.com/dogmatiq/dapper/releases/tag/v0.3.4 [0.3.5]: https://github.com/dogmatiq/dapper/releases/tag/v0.3.5 [0.4.0]: https://github.com/dogmatiq/dapper/releases/tag/v0.4.0 +[0.4.1]: https://github.com/dogmatiq/dapper/releases/tag/v0.4.1 [#6]: https://github.com/dogmatiq/dapper/issues/6 [#7]: https://github.com/dogmatiq/dapper/issues/7 diff --git a/printer.go b/printer.go index 2938ce6..30b4ded 100644 --- a/printer.go +++ b/printer.go @@ -121,7 +121,8 @@ func (p *Printer) Format(v interface{}) string { return b.String() } -var defaultPrinter = Printer{ +// DefaultPrinter is the printer used by Write(), Format() and Print(). +var DefaultPrinter = Printer{ Config: Config{ Filters: []Filter{ ReflectTypeFilter, @@ -137,12 +138,12 @@ var defaultPrinter = Printer{ // // It returns the number of bytes written. func Write(w io.Writer, v interface{}) (int, error) { - return defaultPrinter.Write(w, v) + return DefaultPrinter.Write(w, v) } // Format returns a pretty-printed representation of v. func Format(v interface{}) string { - return defaultPrinter.Format(v) + return DefaultPrinter.Format(v) } var newLine = []byte{'\n'} @@ -153,7 +154,7 @@ func Print(values ...interface{}) { mux.Lock() defer mux.Unlock() for _, v := range values { - defaultPrinter.Write(os.Stdout, v) + DefaultPrinter.Write(os.Stdout, v) os.Stdout.Write(newLine) } }