logging: adds memory scope (#1076)

This allows you to specify the memory scope amongst existing logging scopes, both in API and the CLI.

e.g for the CLI.
```bash
$ wazero run --hostlogging=memory,filesystem --mount=.:/:ro cat.wasm
```

e.g. for Go
```go
loggingCtx := context.WithValue(testCtx, experimental.FunctionListenerFactoryKey{},
	logging.NewHostLoggingListenerFactory(&log, logging.LogScopeMemory|logging.LogScopeFilesystem))
```

This is helpful for emscripten and gojs which have memory reset
callbacks. This will be much more interesting once #1075 is implemented.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-01-29 10:58:59 +02:00
committed by GitHub
parent da99a7f5c0
commit 282ffc5ced
10 changed files with 83 additions and 20 deletions

View File

@@ -41,6 +41,7 @@ const (
LogScopeClock LogScopes = 1 << iota
LogScopeExit
LogScopeFilesystem
LogScopeMemory
LogScopePoll
LogScopeRandom
LogScopeAll = LogScopes(0xffffffffffffffff)
@@ -54,6 +55,8 @@ func scopeName(s LogScopes) string {
return "exit"
case LogScopeFilesystem:
return "filesystem"
case LogScopeMemory:
return "memory"
case LogScopePoll:
return "poll"
case LogScopeRandom: