I understand that I can point print to a different writer, but I don't know what writer to use in order to get my output to appear on stderr.
I'm sure it is something obvious, but I don't know .NET well enough to be able to work out what to do at that end, and I can't immediately see anything in Cobra itself which gives me a stderr stream.
Forums
Writing to stderr
2 posts
• Page 1 of 1
Re: Writing to stderr
On .NET, Console.error is a reference to stderr. It's type is TextWriter.
You can use the print statement on it like so:
Or you can use methods on it like: Console.error.writeLine('x = [x]')
I don't know under what circumstance Console.error may be nil/null. It's up to you if you want to check for that.
See also: http://msdn.microsoft.com/en-us/library/system.console.error.aspx
You can use the print statement on it like so:
# simple case:
err = Console.error to !
print to err, 'x = [x]'
# redirect
print to err
print "error:"
obj.foo
obj.bar
Or you can use methods on it like: Console.error.writeLine('x = [x]')
I don't know under what circumstance Console.error may be nil/null. It's up to you if you want to check for that.
See also: http://msdn.microsoft.com/en-us/library/system.console.error.aspx
- Charles
- Posts: 2515
- Location: Los Angeles, CA
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 52 guests