|
1 | 1 | use anyhow::{anyhow, Result};
|
2 | 2 | use rust_embed::RustEmbed;
|
| 3 | +use std::string::String; |
3 | 4 | use std::{collections::HashSet, io::Cursor, path::PathBuf};
|
4 | 5 | use wasi_common::{I32Exit, WasiCtx};
|
5 | 6 | use wasmtime::{AsContextMut, Config, Engine, Linker, Module, ResourceLimiter, Store};
|
6 | 7 |
|
7 |
| -use crate::{ |
8 |
| - function_run_result::{ |
9 |
| - FunctionOutput::{self, InvalidJsonOutput, JsonOutput}, |
10 |
| - FunctionRunResult, InvalidOutput, |
11 |
| - }, |
12 |
| - logs::LogStream, |
| 8 | +use crate::function_run_result::{ |
| 9 | + FunctionOutput::{self, InvalidJsonOutput, JsonOutput}, |
| 10 | + FunctionRunResult, InvalidOutput, |
13 | 11 | };
|
14 | 12 |
|
15 | 13 | #[derive(Clone)]
|
@@ -130,7 +128,7 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
|
130 | 128 |
|
131 | 129 | let input_stream = wasi_common::pipe::ReadPipe::new(Cursor::new(input.clone()));
|
132 | 130 | let output_stream = wasi_common::pipe::WritePipe::new_in_memory();
|
133 |
| - let error_stream = wasi_common::pipe::WritePipe::new(LogStream::default()); |
| 131 | + let error_stream = wasi_common::pipe::WritePipe::new_in_memory(); |
134 | 132 |
|
135 | 133 | let memory_usage: u64;
|
136 | 134 | let instructions: u64;
|
@@ -195,9 +193,10 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
|
195 | 193 |
|
196 | 194 | let mut logs = error_stream
|
197 | 195 | .try_into_inner()
|
198 |
| - .expect("Log stream reference still exists"); |
| 196 | + .expect("Log stream reference still exists") |
| 197 | + .into_inner(); |
199 | 198 |
|
200 |
| - logs.append(error_logs.as_bytes()); |
| 199 | + logs.extend_from_slice(error_logs.as_bytes()); |
201 | 200 |
|
202 | 201 | let raw_output = output_stream
|
203 | 202 | .try_into_inner()
|
@@ -228,7 +227,7 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
|
228 | 227 | size,
|
229 | 228 | memory_usage,
|
230 | 229 | instructions,
|
231 |
| - logs: logs.to_string(), |
| 230 | + logs: String::from_utf8_lossy(&logs).into(), |
232 | 231 | input: function_run_input,
|
233 | 232 | output,
|
234 | 233 | profile: profile_data,
|
|
0 commit comments