Skip to content

Commit 636525d

Browse files
authored
Simplify logging (#448)
1 parent 597a576 commit 636525d

File tree

3 files changed

+9
-99
lines changed

3 files changed

+9
-99
lines changed

src/engine.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
use anyhow::{anyhow, Result};
22
use rust_embed::RustEmbed;
3+
use std::string::String;
34
use std::{collections::HashSet, io::Cursor, path::PathBuf};
45
use wasi_common::{I32Exit, WasiCtx};
56
use wasmtime::{AsContextMut, Config, Engine, Linker, Module, ResourceLimiter, Store};
67

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,
1311
};
1412

1513
#[derive(Clone)]
@@ -130,7 +128,7 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
130128

131129
let input_stream = wasi_common::pipe::ReadPipe::new(Cursor::new(input.clone()));
132130
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();
134132

135133
let memory_usage: u64;
136134
let instructions: u64;
@@ -195,9 +193,10 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
195193

196194
let mut logs = error_stream
197195
.try_into_inner()
198-
.expect("Log stream reference still exists");
196+
.expect("Log stream reference still exists")
197+
.into_inner();
199198

200-
logs.append(error_logs.as_bytes());
199+
logs.extend_from_slice(error_logs.as_bytes());
201200

202201
let raw_output = output_stream
203202
.try_into_inner()
@@ -228,7 +227,7 @@ pub fn run(params: FunctionRunParams) -> Result<FunctionRunResult> {
228227
size,
229228
memory_usage,
230229
instructions,
231-
logs: logs.to_string(),
230+
logs: String::from_utf8_lossy(&logs).into(),
232231
input: function_run_input,
233232
output,
234233
profile: profile_data,

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub mod bluejay_schema_analyzer;
22
pub mod engine;
33
pub mod function_run_result;
4-
pub mod logs;
54
pub mod scale_limits_analyzer;

src/logs.rs

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)