[golang-dev] code review 1257044: log: add Wtf and Wtff for logging terrible failures. (issue1257044)

14 views
Skip to first unread message

step...@golang.org

unread,
May 23, 2010, 9:01:04 PM5/23/10
to r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
Reviewers: r,

Message:
Hello r (cc: golan...@googlegroups.com),

I'd like you to review this change.


Description:
log: add Wtf and Wtff for logging terrible failures.

cf http://developer.android.com/reference/android/util/Log.html

Please review this at http://codereview.appspot.com/1257044/show

Affected files:
M src/pkg/log/log.go


Index: src/pkg/log/log.go
===================================================================
--- a/src/pkg/log/log.go
+++ b/src/pkg/log/log.go
@@ -56,6 +56,7 @@
var (
stdout = New(os.Stdout, nil, "", Lok|Ldate|Ltime)
stderr = New(os.Stderr, nil, "", Lok|Ldate|Ltime)
+ wtf = New(os.Stderr, nil, "wtf? ", Lok)
exit = New(os.Stderr, nil, "", Lexit|Ldate|Ltime)
crash = New(os.Stderr, nil, "", Lcrash|Ldate|Ltime)
)
@@ -162,12 +163,20 @@
// Stderr is a helper function for easy logging to stderr. It is analogous
to Fprint(os.Stderr).
func Stderr(v ...interface{}) { stderr.Output(2, fmt.Sprintln(v)) }

+// Wtf is a helper function for logging to stderr. It is analogous to
Fprint(os.Stderr),
+// but with output prefixed by the string "wtf?". "wtf" is an acronym
for "what a terrible failure"
+func Wtf(v ...interface{}) { wtf.Output(2, fmt.Sprintln(v)) }
+
// Stdoutf is a helper functions for easy formatted logging to stdout. It
is analogous to Printf().
func Stdoutf(format string, v ...interface{}) { stdout.Output(2,
fmt.Sprintf(format, v)) }

// Stderrf is a helper function for easy formatted logging to stderr. It
is analogous to Fprintf(os.Stderr).
func Stderrf(format string, v ...interface{}) { stderr.Output(2,
fmt.Sprintf(format, v)) }

+// Wtff is a helper function for formatted logging to stderr. It is
analogous to Fprintf(os.Stderr),
+// but with output prefixed by the string "wtf?". "wtf" is an acronym
for "what a terrible failure"
+func Wtff(format string, v ...interface{}) { wtf.Output(2,
fmt.Sprintf(format, v)) }
+
// Exit is equivalent to Stderr() followed by a call to os.Exit(1).
func Exit(v ...interface{}) { exit.Output(2, fmt.Sprintln(v)) }



Rob 'Commander' Pike

unread,
May 24, 2010, 1:07:16 AM5/24/10
to step...@golang.org, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
I don't understand. Are you just looking for another category of log?

-rob

Devon H. O'Dell

unread,
May 24, 2010, 2:21:46 AM5/24/10
to Rob 'Commander' Pike, step...@golang.org, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
2010/5/24 Rob 'Commander' Pike <r...@google.com>:
> I don't understand.  Are you just looking for another category of log?

I'm pretty sure it's a gag. "WTF" is clearly known to mean "What The
Fuck". I see no merit in seriously adding this to the standard
library.

--dho

andrey mirtchovski

unread,
May 24, 2010, 3:33:07 AM5/24/10
to golan...@googlegroups.com

Andrew Gerrand

unread,
May 24, 2010, 2:01:56 PM5/24/10
to step...@golang.org, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
Very cute, but I wouldn't want to read code that uses this.

Rob 'Commander' Pike

unread,
May 24, 2010, 2:45:57 PM5/24/10
to Andrew Gerrand, step...@golang.org, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com

On May 24, 2010, at 11:01 AM, Andrew Gerrand wrote:

> Very cute, but I wouldn't want to read code that uses this.

i have two questions.
1) what is it really for?
2) assuming it's worthwhile, what name should it have?

-rob


Stephen Ma

unread,
May 25, 2010, 8:39:30 PM5/25/10
to Rob 'Commander' Pike, Andrew Gerrand, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
> 1) what is it really for?

It's only there because I didn't want android to have the cute
function named "wtf". It doesn't actually do anything useful.

- S

Stephen Ma

unread,
May 25, 2010, 8:40:12 PM5/25/10
to Rob 'Commander' Pike, Andrew Gerrand, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
> It's only there because I didn't want android to have the cute
> function named "wtf".

That should read "I didn't want android to be the only one to have the

Rob 'Commander' Pike

unread,
May 26, 2010, 2:02:36 PM5/26/10
to Stephen Ma, Andrew Gerrand, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com

I don't consider it a cute name.

-rob

Reply all
Reply to author
Forward
0 new messages