Skip to content

Commit a60d00d

Browse files
committed
runtime: Make it clearer which log messages come from user code
1 parent b5f9496 commit a60d00d

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

runtime/test/src/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pub fn mock_context(
115115
proof_of_indexing: None,
116116
host_fns: Arc::new(Vec::new()),
117117
debug_fork: None,
118+
mapping_logger: Logger::root(slog::Discard, o!()),
118119
}
119120
}
120121

runtime/wasm/src/host.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ where
185185
proof_of_indexing,
186186
host_fns: self.host_fns.cheap_clone(),
187187
debug_fork: debug_fork.cheap_clone(),
188+
mapping_logger: Logger::new(&logger, o!("component" => "UserMapping")),
188189
},
189190
trigger,
190191
result_sender,

runtime/wasm/src/mapping.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ pub struct MappingContext<C: Blockchain> {
124124
pub proof_of_indexing: SharedProofOfIndexing,
125125
pub host_fns: Arc<Vec<HostFn>>,
126126
pub debug_fork: Option<Arc<dyn SubgraphFork>>,
127+
/// Logger for messages coming from mappings
128+
pub mapping_logger: Logger,
127129
}
128130

129131
impl<C: Blockchain> MappingContext<C> {
@@ -136,6 +138,7 @@ impl<C: Blockchain> MappingContext<C> {
136138
proof_of_indexing: self.proof_of_indexing.cheap_clone(),
137139
host_fns: self.host_fns.cheap_clone(),
138140
debug_fork: self.debug_fork.cheap_clone(),
141+
mapping_logger: Logger::new(&self.logger, o!("component" => "UserMapping")),
139142
}
140143
}
141144
}

runtime/wasm/src/module/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ impl<C: Blockchain> WasmInstanceContext<C> {
17091709
let msg: String = asc_get(self, msg, gas)?;
17101710
self.ctx
17111711
.host_exports
1712-
.log_log(&self.ctx.logger, level, msg, gas)
1712+
.log_log(&self.ctx.mapping_logger, level, msg, gas)
17131713
}
17141714

17151715
/// function encode(token: ethereum.Value): Bytes | null

0 commit comments

Comments
 (0)