LCOV - code coverage report
Current view: top level - pageserver/src - trace.rs (source / functions) Coverage Total Hit
Test: fabb29a6339542ee130cd1d32b534fafdc0be240.info Lines: 0.0 % 18 0
Test Date: 2024-06-25 13:20:00 Functions: 0.0 % 4 0

            Line data    Source code
       1              : use bytes::Bytes;
       2              : use camino::Utf8PathBuf;
       3              : use std::{
       4              :     fs::{create_dir_all, File},
       5              :     io::{BufWriter, Write},
       6              : };
       7              : 
       8              : pub struct Tracer {
       9              :     writer: BufWriter<File>,
      10              : }
      11              : 
      12              : impl Drop for Tracer {
      13            0 :     fn drop(&mut self) {
      14            0 :         self.flush()
      15            0 :     }
      16              : }
      17              : 
      18              : impl Tracer {
      19            0 :     pub fn new(path: Utf8PathBuf) -> Self {
      20            0 :         let parent = path.parent().expect("failed to parse parent path");
      21            0 :         create_dir_all(parent).expect("failed to create trace dir");
      22            0 : 
      23            0 :         let file = File::create(path).expect("failed to create trace file");
      24            0 :         Tracer {
      25            0 :             writer: BufWriter::new(file),
      26            0 :         }
      27            0 :     }
      28              : 
      29            0 :     pub fn trace(&mut self, msg: &Bytes) {
      30            0 :         self.writer.write_all(msg).expect("failed to write trace");
      31            0 :     }
      32              : 
      33            0 :     pub fn flush(&mut self) {
      34            0 :         self.writer.flush().expect("failed to flush trace file");
      35            0 :     }
      36              : }
        

Generated by: LCOV version 2.1-beta