Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add traceImportant and traceError with formats #1986

Merged
merged 2 commits into from
Jun 9, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/app/Fake.Core.Trace/Trace.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,24 @@ let traceVerbose s =
/// Writes a trace to stderr (in yellow)
let traceImportant text = CoreTracing.postMessage (TraceData.ImportantMessage text)

/// Writes a message to stderr (in yellow)
let traceImportantfn fmt = Printf.ksprintf traceImportant fmt

/// Writes a message to stderr (in yellow) and without a line break
let traceImportantf fmt = Printf.ksprintf (fun text -> CoreTracing.postMessage (TraceData.ImportantMessage(text))) fmt

/// Writes a trace to the command line (in yellow)
let traceFAKE fmt = Printf.ksprintf (TraceData.ImportantMessage >> CoreTracing.postMessage) fmt

/// Traces an error (in red)
let traceError error = CoreTracing.postMessage (TraceData.ErrorMessage error)

/// Writes an error message to stderr (in red)
let traceErrorfn fmt = Printf.ksprintf traceError fmt

/// Writes an error message to stderr (in red) and without a line break
let traceErrorf fmt = Printf.ksprintf (fun text -> CoreTracing.postMessage (TraceData.ErrorMessage(text))) fmt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think we need to leave out the f variants as they shouldn't print a newline character. I think your implementation will

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the method from other f variants...happy to remove them though, I don't get the use case of the f methods

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the , false parameter - which doesn't exist for those types for some reason.

I don't get the use case of the f methods

One use case is to realise some prompt to the user like
Please enter value for X: | and have the cursor sitting at | instead of the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh now it makes perfect sense!
I can't think why someone would need important or error version anyways then. So I'll remove.


open Microsoft.FSharp.Core.Printf

/// Converts an exception and its inner exceptions to a nice string.
Expand Down