Skip to content

Commit

Permalink
🚧 Commit sandbox changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rster2002 committed May 11, 2024
1 parent ba9866f commit daf6854
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 51 deletions.
2 changes: 1 addition & 1 deletion sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ed-journals = { path = "../ed-journals", features = ["strict", "blocking", "async"] }
ed-journals = { path = "../ed-journals", features = ["strict", "blocking", "asynchronous"] }
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
32 changes: 1 addition & 31 deletions sandbox/log-dir/Journal.2024-01-01T154931.01.log
Original file line number Diff line number Diff line change
Expand Up @@ -989,34 +989,4 @@
{"timestamp":"2024-01-01T17:31:56Z","event":"Music","MusicTrack":"Exploration"}
{"timestamp":"2024-01-01T17:31:56Z","event":"ShipLocker","Items":[],"Components":[],"Consumables":[{"Name":"energycell","Name_Localised":"Energy Cell","OwnerID":0,"Count":2}],"Data":[{"Name":"evacuationprotocols","Name_Localised":"Evacuation Protocols","OwnerID":0,"Count":1}]}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}
{"timestamp":"2024-01-01T17:32:12Z","event":"Shutdown"}

26 changes: 25 additions & 1 deletion sandbox/log-dir/Status.json
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
{ "timestamp":"2024-05-09T16:50:32Z", "event":"Status", "Flags":151060493, "Flags2":0, "Pips":[4,4,4], "FireGroup":0, "GuiFocus":0, "Fuel":{ "FuelMain":32.000000, "FuelReservoir":0.520000 }, "Cargo":0.000000, "LegalState":"Clean", "Balance":3183336476, "Destination":{ "System":2871319930265, "Body":0, "Name":"Morommo" } }
{
"timestamp": "2024-05-09T16:50:32Z",
"event": "Status",
"Flags": 151060493,
"Flags2": 0,
"Pips": [
4,
4,
4
],
"FireGroup": 0,
"GuiFocus": 0,
"Fuel": {
"FuelMain": 32.000000,
"FuelReservoir": 0.520000
},
"Cargo": 0.000000,
"LegalState": "Clean",
"Balance": 3183336476,
"Destination": {
"System": 2871319930265,
"Body": 0,
"Name": "Morommo"
}
}
48 changes: 30 additions & 18 deletions sandbox/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
use std::env::current_dir;
use std::path::PathBuf;
use tokio::fs::File;
use ed_journals::r#async::LiveJournalDirReader;
use ed_journals::r#async::LiveJournalFileReader;
use ed_journals::r#async::JournalFileReader;
use ed_journals::logs::asynchronous::LiveLogDirReader;
use ed_journals::status::blocking::StatusFileWatcher;

#[tokio::main]
async fn main() {
let dir_path = current_dir()
.unwrap()
.join("log-dir");
// .join("Journal.2024-01-01T154931.01.log");
//
// let file = File::open()
// .await
// .unwrap();
let watcher = StatusFileWatcher::new(PathBuf::from("./log-dir/Status.json"))
.unwrap();

for update in watcher {
dbg!(update);
}

// let mut reader = LiveJournalFileReader::create(dir_path.join("Journal.2024-01-01T154931.01.log"))
// .await
// let status = ed_journals::status::blocking::read_status_file("./log-dir/Status.json")
// .unwrap();
//
let mut reader = LiveJournalDirReader::create(dir_path)
.unwrap();
// dbg!(status);

while let Some(entry) = reader.next().await {
dbg!(entry);
}
// let dir_path = current_dir()
// .unwrap()
// .join("log-dir");
// // .join("Journal.2024-01-01T154931.01.log");
// //
// // let file = File::open()
// // .await
// // .unwrap();
//
// // let mut reader = LiveJournalFileReader::create(dir_path.join("Journal.2024-01-01T154931.01.log"))
// // .await
// // .unwrap();
// //
// let mut reader = LiveLogDirReader::open(dir_path)
// .unwrap();
//
// while let Some(entry) = reader.next().await {
// dbg!(entry);
// }
}

0 comments on commit daf6854

Please sign in to comment.