fixed logfile odd single bracket
This commit is contained in:
parent
b8079b0981
commit
5acce18dd8
@ -32,7 +32,7 @@ hyper-util = "0.1.7"
|
||||
hyper-rustls = { version = "0.27", features = ["http2"] }
|
||||
detee-sgx = { git = "ssh://git@gitea.detee.cloud/SGX/detee-sgx", branch = "hacker-challenge", features = ["tonic", "occlum", "sealing"] }
|
||||
|
||||
|
||||
once_cell = "1.20.2"
|
||||
env_logger = "0.11"
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -4,11 +4,15 @@ use detee_sgx::SgxError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{base64::Base64, serde_as};
|
||||
use std::io::Write;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::Mutex;
|
||||
pub struct Logfile {}
|
||||
|
||||
static LOG_MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
|
||||
|
||||
impl Logfile {
|
||||
pub fn append(path: &str, msg: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let _lock = LOG_MUTEX.lock();
|
||||
let mut file = std::fs::OpenOptions::new().create(true).append(true).open(path)?;
|
||||
file.write_all(msg.as_bytes())?;
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user