Skip to content

Commit 59ff910

Browse files
authored
Merge pull request #7 from iCog-Labs-Dev/feature/logger
Feature/logger
2 parents 294c98f + e303b00 commit 59ff910

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

metta-run/release/metta-run

4 KB
Binary file not shown.

metta-run/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod formatters;
55
mod runners;
66
mod tools;
77

8+
89
fn main() -> io::Result<()> {
910
#[derive(Parser)]
1011
#[command(name = "metta-run")]
@@ -26,7 +27,8 @@ fn main() -> io::Result<()> {
2627

2728
let start_time = tools::logger::start_timer();
2829
let metta_output = runners::metta::run(file);
29-
tools::logger::stop_timer(start_time, &metta_output)?;
30+
31+
let _ = tools::logger::stop_timer(start_time, &metta_output);
3032

3133
if let Some(command) = args.commands {
3234
match command {

metta-run/src/tools/logger.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::env;
33
use std::fs::OpenOptions;
44
use std::io::Write;
55
use std::time::Instant;
6+
use std::env::current_dir;
67

78
pub fn start_timer() -> Instant {
89
Instant::now()
@@ -12,8 +13,15 @@ pub fn stop_timer(start_time: Instant, metta_output: &String) -> Result<(), std:
1213
let now = Local::now();
1314
let formatted_date = now.format("%Y-%m-%d").to_string();
1415

15-
let metta_bin = format!("{}/metta-bin/", env::var("HOME").unwrap());
16-
let log_file_name = format!("{}{}.log", metta_bin, formatted_date);
16+
17+
let file_path: Option<String> = match current_dir() {
18+
Ok(path) => Some(path.to_string_lossy().into_owned()),
19+
Err(error) => None
20+
};
21+
let log_file_name = match file_path {
22+
Some(path) => format!("{}/{}.log", path, formatted_date),
23+
None => todo!()
24+
};
1725

1826
let end_time = Instant::now();
1927
let elapsed_time = end_time.duration_since(start_time);

0 commit comments

Comments
 (0)