Closed ctaggart closed 10 years ago
I was hoping to be able to split up logging by each target, but several of the log statements, but it looks like the CloseTag "target"
may be getting called before logging the messages.
I just created an in memory listener for troubleshooting.
type TargetLog(name) =
member x.Name with get() = name
member val Messages = List<string>() with get, set
member val Children = List<TargetLog>() with get, set
type TargetLogListener() =
let root = TargetLog "root"
let mutable target = root
interface ITraceListener with
member x.Write msg =
match msg with
| OpenTag(tag,name) ->
if tag.Equals "target" then
let t = TargetLog name
root.Children.Add t
target <- t
| StartMessage -> ()
| ImportantMessage text -> target.Messages.Add text
| LogMessage(text,newLine) -> target.Messages.Add text
| TraceMessage(text,newLine) -> target.Messages.Add text
| ErrorMessage text -> target.Messages.Add text
| FinishedMessage -> ()
| CloseTag tag ->
if tag.Equals "target" then
target <- root
member x.Root with get() = root
Target "Summary" (fun _ ->
logfn "this is Summary"
let rec printLogNode (t:TargetLog) indent =
for m in t.Messages do
printfn "%s%s> %s" indent t.Name m
for c in t.Children do
printLogNode c (indent + " ")
printLogNode memListener.Root " "
()
)
/cc @forki
oh that doesn't look good.
For my own notes, the in progress TfsLogListener
that was trying to group log statements by target looks like this:
type TfsLogListener(bi:IBuildInformation) =
let defaultTarget = bi.AddBuildStep("no target", "no target", DateTime.UtcNow, BuildStepStatus.Unknown)
let mutable target = defaultTarget
interface ITraceListener with
member x.Write msg =
match msg with
| OpenTag(tag,name) ->
if tag.Equals "target" then
target <- bi.AddBuildStep(name, name, DateTime.UtcNow, BuildStepStatus.Unknown)
| StartMessage -> ()
| ImportantMessage text ->
target.Node.Children.AddBuildMessage(text, BuildMessageImportance.High, DateTime.UtcNow) |> ignore
| LogMessage(text,newLine) ->
target.Node.Children.AddBuildMessage(text, BuildMessageImportance.Normal, DateTime.UtcNow) |> ignore
| TraceMessage(text,newLine) ->
target.Node.Children.AddBuildMessage(text, BuildMessageImportance.Low, DateTime.UtcNow) |> ignore
| ErrorMessage text ->
target.Node.Children.AddBuildError(text, DateTime.UtcNow) |> ignore
| FinishedMessage -> ()
| CloseTag tag ->
if tag.Equals "target" then
target.FinishTime <- DateTime.UtcNow
target <- defaultTarget
bi.Save()
if isTfsBuild then
listeners.Clear()
listeners.Add(TfsLogListener(getTfsBuild().Build.Information))
This has been working since that issue was fixed in FAKE.
from work in progress in Fake.fsx. It looks like It is a heirachy of IBuildInformationNodes. The AddBuildMessage didn't do anything. The AddBuildStep aded a category with nothing under it. The dates may need to be DateTime.Now instead. Not sure.