Files
filestash/server/plugin/plg_runtime_cookbook/filesystem/lib.rs
T

36 lines
713 B
Rust

use filestash::*;
use std::fs::OpenOptions;
use std::io::Write;
pub struct Plugin;
impl App for Plugin {
fn new() -> Self {
Plugin
}
}
impl OnInit for Plugin {
fn on_init(&self) {
append("the server has started\n");
}
}
impl OnDestroy for Plugin {
fn on_destroy(&self) {
append("the server has stopped\n");
}
}
fn append(line: &str) {
let mut file = OpenOptions::new()
.create(true)
.append(true)
.open("/{{ .TMP_PATH }}/example.log")
.unwrap();
file.write_all(line.as_bytes()).unwrap();
log::info!("[runtime::plugin::filesystem] appended to example.log: {}", line.trim());
}
register!(Plugin: OnInit + OnDestroy);