diff --git a/docs/examples/lib/1-d2lib/d2lib.go b/docs/examples/lib/1-d2lib/d2lib.go index 58f2ddc404..d75eedc32e 100644 --- a/docs/examples/lib/1-d2lib/d2lib.go +++ b/docs/examples/lib/1-d2lib/d2lib.go @@ -2,7 +2,7 @@ package main import ( "context" - "io/ioutil" + "os" "path/filepath" "oss.terrastruct.com/d2/d2graph" @@ -10,6 +10,7 @@ import ( "oss.terrastruct.com/d2/d2lib" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2themes/d2themescatalog" + "oss.terrastruct.com/d2/lib/log" "oss.terrastruct.com/d2/lib/textmeasure" "oss.terrastruct.com/util-go/go2" ) @@ -28,7 +29,8 @@ func main() { LayoutResolver: layoutResolver, Ruler: ruler, } - diagram, _, _ := d2lib.Compile(context.Background(), "x -> y", compileOpts, renderOpts) + ctx := log.WithDefault(context.Background()) + diagram, _, _ := d2lib.Compile(ctx, "x -> y", compileOpts, renderOpts) out, _ := d2svg.Render(diagram, renderOpts) - _ = ioutil.WriteFile(filepath.Join("out.svg"), out, 0600) + _ = os.WriteFile(filepath.Join("out.svg"), out, 0600) } diff --git a/docs/examples/lib/2-d2oracle/d2oracle.go b/docs/examples/lib/2-d2oracle/d2oracle.go index b59dca1fe6..067b5b4b53 100644 --- a/docs/examples/lib/2-d2oracle/d2oracle.go +++ b/docs/examples/lib/2-d2oracle/d2oracle.go @@ -9,6 +9,7 @@ import ( "oss.terrastruct.com/d2/d2layouts/d2dagrelayout" "oss.terrastruct.com/d2/d2lib" "oss.terrastruct.com/d2/d2oracle" + "oss.terrastruct.com/d2/lib/log" "oss.terrastruct.com/d2/lib/textmeasure" ) @@ -23,7 +24,8 @@ func main() { LayoutResolver: layoutResolver, Ruler: ruler, } - _, graph, _ := d2lib.Compile(context.Background(), "x -> y", compileOpts, nil) + ctx := log.WithDefault(context.Background()) + _, graph, _ := d2lib.Compile(ctx, "x -> y", compileOpts, nil) // Create a shape with the ID, "meow" graph, _, _ = d2oracle.Create(graph, nil, "meow") diff --git a/docs/examples/lib/3-lowlevel/lowlevel.go b/docs/examples/lib/3-lowlevel/lowlevel.go index 53f0468e77..89b10d13d4 100644 --- a/docs/examples/lib/3-lowlevel/lowlevel.go +++ b/docs/examples/lib/3-lowlevel/lowlevel.go @@ -2,7 +2,7 @@ package main import ( "context" - "io/ioutil" + "os" "path/filepath" "strings" @@ -11,6 +11,7 @@ import ( "oss.terrastruct.com/d2/d2layouts/d2dagrelayout" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2themes/d2themescatalog" + "oss.terrastruct.com/d2/lib/log" "oss.terrastruct.com/d2/lib/textmeasure" ) @@ -20,11 +21,12 @@ func main() { graph.ApplyTheme(d2themescatalog.NeutralDefault.ID) ruler, _ := textmeasure.NewRuler() _ = graph.SetDimensions(nil, ruler, nil) - _ = d2dagrelayout.Layout(context.Background(), graph, nil) - diagram, _ := d2exporter.Export(context.Background(), graph, nil) + ctx := log.WithDefault(context.Background()) + _ = d2dagrelayout.Layout(ctx, graph, nil) + diagram, _ := d2exporter.Export(ctx, graph, nil) diagram.Config = config out, _ := d2svg.Render(diagram, &d2svg.RenderOpts{ ThemeID: &d2themescatalog.NeutralDefault.ID, }) - _ = ioutil.WriteFile(filepath.Join("out.svg"), out, 0600) + _ = os.WriteFile(filepath.Join("out.svg"), out, 0600) }