-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cyteon
committed
Jul 15, 2024
1 parent
4199586
commit 382bdf3
Showing
5 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import birl | ||
import gleam/io | ||
import gleam/list | ||
import gleam/string | ||
|
||
fn get_date_string() -> String { | ||
let now = birl.now() | ||
let date_string_with_timezone = birl.to_date_string(now) | ||
let time_string_with_timezone = birl.to_time_string(now) | ||
|
||
// Removing timezone from date string | ||
let date_parts = string.split(date_string_with_timezone, "+") | ||
let date_without_timezone = case list.first(date_parts) { | ||
Ok(value) -> value | ||
Error(_) -> date_string_with_timezone | ||
} | ||
|
||
// Removing timezone from time string | ||
let time_parts = string.split(time_string_with_timezone, "+") | ||
let time_without_timezone = case list.first(time_parts) { | ||
Ok(value) -> value | ||
Error(_) -> date_string_with_timezone | ||
} | ||
|
||
date_without_timezone <> " " <> time_without_timezone | ||
} | ||
|
||
pub fn println(content: String, log_type: String) { | ||
let log_splitter = case log_type { | ||
"info" -> "\u{001b}[34mINFO" | ||
"warn" -> "\u{001b}[33mWARN" | ||
"error" -> "\u{001b}[31mERROR" | ||
_ -> "\u{001b}[32mLOG" | ||
} | ||
|
||
io.println( | ||
get_date_string() <> " | " <> log_splitter <> "\u{001b}[0m | " <> content, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters