You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: context_log.rs
    path of file: ./repos/holochain/crates/hc_sleuth/src
    
    the code of the file until where you have to start completion: use std::{collections::HashSet, io::BufRead};

use holochain_types::prelude::*;
use once_cell::sync::OnceCell;
use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt};

use super::*;

pub type ContextSubscriber = aitia::logging::AitiaSubscriber<Context>;

// #[derive(Debug, derive_more::From)]
pub type CtxError = String;
pub type ContextResult<T> = Result<T, CtxError>;

pub fn init_subscriber() -> ContextSubscriber {
    let w = SUBSCRIBER.get_or_init(ContextSubscriber::default).clone();
    let ww = w.clone();
    tracing_subscriber::registry()
        .with(holochain_trace::standard_layer(std::io::stderr).unwrap())
        .with(aitia::logging::tracing_layer(move || ww.clone()))
        .init();
    w
}

pub static SUBSCRIBER: OnceCell<ContextSubscriber> = OnceCell::new();

#[derive(Default, Debug)]
pub struct Context {
    /// All facts ever recorded
    pub facts: HashSet<Event>,

    /// Track which agents are part of which nodes
    pub map_node_to_agents: HashMap<SleuthId, HashSet<AgentPubKey>>,

    /// Track which node an agent is part of
    pub map_agent_to_node: HashMap<AgentPubKey, SleuthId>,

    /// Track the sys validation deps for an op hash
    pub map_op_to_sysval_dep_hash: HashMap<OpRef, Option<ActionHash>>,

    /// Track the app validation deps for an op hash
    pub map_op_to_appval_dep_hash: HashMap<OpRef, HashSet<AnyDhtHash>>,

    /// Track which op a dependency is part of
    pub map_dep_hash_to_op: HashMap<AnyDhtHash, OpRef>,

    /// Map the (action hash + op type) representation to the actual op hash
    pub map_action_to_op: HashMap<OpAction, OpRef>,

    
    fn apply(&mut self, fact: Event) {
        match fact.clone() {
            Event::Integrated { .. } => {}
            Event::AppValidated { .. } => {}
            Event::SysValidated { .. } => {}
            Event::MissingAppValDep { by: _, op, deps } => {
                self.map_op_to_appval_dep_hash
                    .entry(op)
                    .or_default()
                    .extend(deps);
            }
            Event::Fetched { .. } => {}
            Event::ReceivedHash { .. } => {}
            Event::SentHash { .. } => {}
            Event::Authored { by: _, op } => {
                // TODO: add check that the same op is not authored twice?
                let op_hash = op.as_hash();
                let a = OpAction::from((*op).clone());
                self.map_dep_hash_to_op
                    .insert(op.fetch_dependency_hash(), op_hash.clone());
                self.map_action_to_op.insert(a, op_hash.clone());
                self.map_op_to_sysval_dep_hash
                    .insert(op_hash.clone(), op.dep.clone());
                self.op_info.insert(op_hash.clone(), op);
            }
            Event::AgentJoined { node, agent } => {
                self.map_agent_to_node.insert(agent.clone(), node.clone());
                self.map_node_to_agents
                    .entry(node)
                    .or_default()
                    .insert(agent);
            }
            Event::SweetConductorShutdown { node } => {
                if let Some(agents) = self.map_node_to_agents.remove(&node) {
                    for a in agents {
                        self.map_agent_to_node.remove(&a);
                    }
                }
            }
        }
        let duplicate = self.facts.insert(fact.clone());
        if duplicate {
            tracing::warn!("Duplicate fact {:?}", fact);
        }
    }