Remove the dot graphs from the debug log,

and record the walk visits in the debug information.
This commit is contained in:
James Bardin 2016-11-15 10:30:50 -05:00
parent 6d30b60144
commit bb137f4bfb
4 changed files with 4 additions and 64 deletions

View File

@ -224,40 +224,6 @@ func (d *debugInfo) flush() {
}
}
// WriteGraph takes a DebugGraph and writes both the DebugGraph as a dot file
// in the debug archive, and extracts any logs that the DebugGraph collected
// and writes them to a log file in the archive.
func (d *debugInfo) WriteGraph(name string, g *Graph) error {
if d == nil || g == nil {
return nil
}
d.Lock()
defer d.Unlock()
// If we crash, the file won't be correctly closed out, but we can rebuild
// the archive if we have to as long as every file has been flushed and
// sync'ed.
defer d.flush()
dotPath := fmt.Sprintf("%s/graphs/%d-%s-%s.dot", d.name, d.step, d.phase, name)
d.step++
dotBytes := g.Dot(nil)
hdr := &tar.Header{
Name: dotPath,
Mode: 0644,
Size: int64(len(dotBytes)),
}
err := d.tar.WriteHeader(hdr)
if err != nil {
return err
}
_, err = d.tar.Write(dotBytes)
return err
}
// WriteFile writes data as a single file to the debug arhive.
func (d *debugInfo) WriteFile(name string, data []byte) error {
if d == nil {

View File

@ -16,7 +16,6 @@ func TestDebugInfo_nil(t *testing.T) {
var d *debugInfo
d.SetPhase("none")
d.WriteGraph("", nil)
d.WriteFile("none", nil)
d.Close()
}
@ -120,9 +119,7 @@ func TestDebug_plan(t *testing.T) {
}
tr := tar.NewReader(gz)
files := 0
graphs := 0
json := 0
graphLogs := 0
for {
hdr, err := tr.Next()
if err == io.EOF {
@ -134,28 +131,13 @@ func TestDebug_plan(t *testing.T) {
// record any file that contains data
if hdr.Size > 0 {
files++
// and any dot graph with data
if strings.HasSuffix(hdr.Name, ".dot") {
graphs++
}
if strings.HasSuffix(hdr.Name, "graph.json") {
json++
graphLogs++
}
}
}
if files == 0 {
t.Fatal("no files with data found")
}
if graphs == 0 {
t.Fatal("no no-empty graphs found")
}
if json == 0 {
if graphLogs == 0 {
t.Fatal("no json graphs")
}
}

View File

@ -246,6 +246,7 @@ func (g *Graph) walk(walker GraphWalker) error {
var walkFn dag.WalkFunc
walkFn = func(v dag.Vertex) (rerr error) {
log.Printf("[DEBUG] vertex '%s.%s': walking", path, dag.VertexName(v))
g.DebugVisitInfo(v, g.debugName)
// If we have a panic wrap GraphWalker and a panic occurs, recover
// and call that. We ensure the return value is an error, however,

View File

@ -58,19 +58,10 @@ func (b *BasicGraphBuilder) Build(path []string) (*Graph, error) {
}
debugOp.End(errMsg)
// always log the graph state to see what transformations may have happened
debugName := "build-" + stepName
if b.Name != "" {
debugName = b.Name + "-" + debugName
}
log.Printf(
"[TRACE] Graph after step %T:\n\n%s",
step, g.StringWithNodeTypes())
// TODO: replace entirely with the json logs
dbug.WriteGraph(debugName, g)
if err != nil {
return g, err
}