lang: Clean up import logs

We get a lot of useless noise here, make it neater.
This commit is contained in:
James Shubin
2024-09-28 21:56:53 -04:00
parent 761030b5b8
commit 6397c8f930
3 changed files with 34 additions and 13 deletions

View File

@@ -3503,21 +3503,26 @@ func (obj *StmtProg) importSystemScope(name string) (*interfaces.Scope, error) {
obj.data.Logf("behold, the AST: %+v", ast) obj.data.Logf("behold, the AST: %+v", ast)
} }
obj.data.Logf("init...") //obj.data.Logf("init...")
//obj.data.Logf("import: %s", ?) // TODO: add this for symmetry?
// init and validate the structure of the AST // init and validate the structure of the AST
// some of this might happen *after* interpolate in SetScope or later... // some of this might happen *after* interpolate in SetScope or later...
if err := ast.Init(obj.data); err != nil { if err := ast.Init(obj.data); err != nil {
return nil, errwrap.Wrapf(err, "could not init and validate AST") return nil, errwrap.Wrapf(err, "could not init and validate AST")
} }
obj.data.Logf("interpolating...") if obj.data.Debug {
obj.data.Logf("interpolating...")
}
// interpolate strings and other expansionable nodes in AST // interpolate strings and other expansionable nodes in AST
interpolated, err := ast.Interpolate() interpolated, err := ast.Interpolate()
if err != nil { if err != nil {
return nil, errwrap.Wrapf(err, "could not interpolate AST from import `%s`", name) return nil, errwrap.Wrapf(err, "could not interpolate AST from import `%s`", name)
} }
obj.data.Logf("scope building...") if obj.data.Debug {
obj.data.Logf("scope building...")
}
// propagate the scope down through the AST... // propagate the scope down through the AST...
// most importantly, we ensure that the child imports will run! // most importantly, we ensure that the child imports will run!
// we pass in *our* parent scope, which will include the globals // we pass in *our* parent scope, which will include the globals
@@ -3602,7 +3607,8 @@ func (obj *StmtProg) importScopeWithParsedInputs(input *inputs.ParsedInput, scop
// nested logger // nested logger
logf := func(format string, v ...interface{}) { logf := func(format string, v ...interface{}) {
obj.data.Logf("import: "+format, v...) //obj.data.Logf("import: "+format, v...) // don't nest!
obj.data.Logf(format, v...)
} }
// build new list of files // build new list of files
@@ -3623,7 +3629,8 @@ func (obj *StmtProg) importScopeWithParsedInputs(input *inputs.ParsedInput, scop
logf("behold, the AST: %+v", ast) logf("behold, the AST: %+v", ast)
} }
logf("init...") //logf("init...")
logf("import: %s", input.Base)
// init and validate the structure of the AST // init and validate the structure of the AST
data := &interfaces.Data{ data := &interfaces.Data{
// TODO: add missing fields here if/when needed // TODO: add missing fields here if/when needed
@@ -3649,14 +3656,18 @@ func (obj *StmtProg) importScopeWithParsedInputs(input *inputs.ParsedInput, scop
return nil, errwrap.Wrapf(err, "could not init and validate AST") return nil, errwrap.Wrapf(err, "could not init and validate AST")
} }
logf("interpolating...") if obj.data.Debug {
logf("interpolating...")
}
// interpolate strings and other expansionable nodes in AST // interpolate strings and other expansionable nodes in AST
interpolated, err := ast.Interpolate() interpolated, err := ast.Interpolate()
if err != nil { if err != nil {
return nil, errwrap.Wrapf(err, "could not interpolate AST from import") return nil, errwrap.Wrapf(err, "could not interpolate AST from import")
} }
logf("scope building...") if obj.data.Debug {
logf("scope building...")
}
// propagate the scope down through the AST... // propagate the scope down through the AST...
// most importantly, we ensure that the child imports will run! // most importantly, we ensure that the child imports will run!
// we pass in *our* parent scope, which will include the globals // we pass in *our* parent scope, which will include the globals

View File

@@ -189,7 +189,8 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) {
} }
importGraph.AddVertex(importVertex) importGraph.AddVertex(importVertex)
logf("init...") //logf("init...")
logf("import: %s", output.Base)
// init and validate the structure of the AST // init and validate the structure of the AST
data := &interfaces.Data{ data := &interfaces.Data{
// TODO: add missing fields here if/when needed // TODO: add missing fields here if/when needed
@@ -219,7 +220,9 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) {
return nil, errwrap.Wrapf(err, "could not init and validate AST") return nil, errwrap.Wrapf(err, "could not init and validate AST")
} }
logf("interpolating...") if debug {
logf("interpolating...")
}
// interpolate strings and other expansionable nodes in AST // interpolate strings and other expansionable nodes in AST
iast, err := xast.Interpolate() iast, err := xast.Interpolate()
if err != nil { if err != nil {
@@ -249,7 +252,9 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) {
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
} }
logf("scope building...") if debug {
logf("scope building...")
}
// propagate the scope down through the AST... // propagate the scope down through the AST...
// We use SetScope because it follows all of the imports through. I did // We use SetScope because it follows all of the imports through. I did
// not think we needed to pass in an initial scope because the download // not think we needed to pass in an initial scope because the download

View File

@@ -173,7 +173,8 @@ func (obj *Lang) Init(ctx context.Context) error {
} }
importGraph.AddVertex(importVertex) importGraph.AddVertex(importVertex)
obj.Logf("init...") //obj.Logf("init...")
obj.Logf("import: %s", output.Base)
// init and validate the structure of the AST // init and validate the structure of the AST
data := &interfaces.Data{ data := &interfaces.Data{
// TODO: add missing fields here if/when needed // TODO: add missing fields here if/when needed
@@ -203,7 +204,9 @@ func (obj *Lang) Init(ctx context.Context) error {
return errwrap.Wrapf(err, "could not init and validate AST") return errwrap.Wrapf(err, "could not init and validate AST")
} }
obj.Logf("interpolating...") if obj.Debug {
obj.Logf("interpolating...")
}
timing = time.Now() timing = time.Now()
// interpolate strings and other expansionable nodes in AST // interpolate strings and other expansionable nodes in AST
iast, err := xast.Interpolate() iast, err := xast.Interpolate()
@@ -233,7 +236,9 @@ func (obj *Lang) Init(ctx context.Context) error {
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
} }
obj.Logf("scope building...") if obj.Debug {
obj.Logf("scope building...")
}
timing = time.Now() timing = time.Now()
// propagate the scope down through the AST... // propagate the scope down through the AST...
if err := obj.ast.SetScope(scope); err != nil { if err := obj.ast.SetScope(scope); err != nil {