-
Notifications
You must be signed in to change notification settings - Fork 525
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
Paket.PowerShell support for Package Manager Console #875
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c17bdbc
refactor Logging to use Trace observable
66e3fcd
filter only main thread for PS,
e688bc7
added EventSink to support logging on main thread
f72527a
use async try finally
9ba9928
removed commented out code
36ea71b
added `use` to dispose of EventSink
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Paket.Logging | ||
|
||
open System | ||
open System.Diagnostics | ||
|
||
val mutable verbose : bool | ||
|
||
|
||
val tracen : string -> unit | ||
|
||
val tracefn : Printf.StringFormat<'a,unit> -> 'a | ||
|
||
val trace : string -> unit | ||
|
||
val tracef : Printf.StringFormat<'a,unit> -> 'a | ||
|
||
val traceVerbose : string -> unit | ||
|
||
val verbosefn : Printf.StringFormat<'a,unit> -> 'a | ||
|
||
val traceError : string -> unit | ||
|
||
val traceWarn : string -> unit | ||
|
||
val traceErrorfn : Printf.StringFormat<'a,unit> -> 'a | ||
|
||
val traceWarnfn : Printf.StringFormat<'a,unit> -> 'a | ||
|
||
|
||
type Trace = { | ||
Level: TraceLevel | ||
Text: string | ||
NewLine: bool } | ||
|
||
val subscribe : (Trace -> unit) -> IDisposable | ||
|
||
val traceToConsole : Trace -> unit | ||
|
||
val setLogFile : string -> IDisposable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
module Paket.PowerShell.CmdletExt | ||
|
||
open System.Management.Automation | ||
open System | ||
open System.Diagnostics | ||
open Paket | ||
|
||
// add F# printf write extensions | ||
type Cmdlet with | ||
|
@@ -37,4 +40,17 @@ type PSCmdlet with | |
else false | ||
|
||
member x.SetCurrentDirectoryToLocation() = | ||
System.Environment.CurrentDirectory <- x.SessionState.Path.CurrentFileSystemLocation.Path | ||
Environment.CurrentDirectory <- x.SessionState.Path.CurrentFileSystemLocation.Path | ||
|
||
member x.RegisterTrace() = | ||
Logging.verbose <- x.Verbose | ||
let id = Threading.Thread.CurrentThread.ManagedThreadId | ||
Logging.subscribe (fun trace -> | ||
if id = Threading.Thread.CurrentThread.ManagedThreadId then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This thread ID check appears it will work. Messages in |
||
match trace.Level with | ||
| TraceLevel.Warning -> x.WriteWarning trace.Text | ||
| TraceLevel.Error -> x.WriteWarning trace.Text | ||
| _ -> x.WriteObject trace.Text | ||
else | ||
Diagnostics.Debug.Write(sprintf "not on main PS thread: %A" trace) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who was using this? Will
Logging.subscribe
work for them or does this need to be added back (may be call itsubscribeWithAction
). It would return aIDisposable
instead of havingRemoveTraceFunction
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume Paket.VisualStudio is using this. But we can fix breaking changes
there
On Jun 15, 2015 10:13, "Cameron Taggart" [email protected] wrote: