github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/assemblyscript/logging/logging.go (about) 1 package logging 2 3 import ( 4 "github.com/bananabytelabs/wazero/api" 5 . "github.com/bananabytelabs/wazero/internal/assemblyscript" 6 "github.com/bananabytelabs/wazero/internal/logging" 7 ) 8 9 func isProcFunction(fnd api.FunctionDefinition) bool { 10 return fnd.ExportNames()[0] == AbortName 11 } 12 13 func isRandomFunction(fnd api.FunctionDefinition) bool { 14 return fnd.ExportNames()[0] == SeedName 15 } 16 17 // IsInLogScope returns true if the current function is in any of the scopes. 18 func IsInLogScope(fnd api.FunctionDefinition, scopes logging.LogScopes) bool { 19 if scopes.IsEnabled(logging.LogScopeProc) { 20 if isProcFunction(fnd) { 21 return true 22 } 23 } 24 25 if scopes.IsEnabled(logging.LogScopeRandom) { 26 if isRandomFunction(fnd) { 27 return true 28 } 29 } 30 31 return scopes == logging.LogScopeAll 32 }