-
Notifications
You must be signed in to change notification settings - Fork 88
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
1 parent
2991137
commit 068b5f4
Showing
7 changed files
with
122 additions
and
26 deletions.
There are no files selected for viewing
File renamed without changes.
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 @@ | ||
Commit message: `config - and fix other things` (default-config) |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
subscription DeploymentLogs( | ||
$deploymentId: String! | ||
$filter: String | ||
$limit: Int | ||
) { | ||
deploymentLogs(deploymentId: $deploymentId, filter: $filter, limit: $limit) { | ||
...LogFields | ||
} | ||
subscription DeploymentLogs($deploymentId: String!, $filter: String, $limit: Int) { | ||
deploymentLogs(deploymentId: $deploymentId, filter: $filter, limit: $limit) { | ||
...LogFields | ||
} | ||
} | ||
|
||
fragment LogFields on Log { | ||
timestamp | ||
message | ||
} | ||
timestamp | ||
message | ||
attributes { | ||
key | ||
value | ||
} | ||
} |
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,58 @@ | ||
use crate::subscriptions; | ||
use colored::Colorize; | ||
|
||
pub fn format_attr_log(log: subscriptions::deployment_logs::LogFields) { | ||
// we love inconsistencies! | ||
if log.attributes.is_empty() | ||
|| (log.attributes.len() == 1 | ||
&& log | ||
.attributes | ||
.first() | ||
.is_some_and(|attr| attr.key == "level")) | ||
{ | ||
println!("{}", log.message); | ||
return; | ||
} | ||
|
||
let mut level: Option<String> = None; | ||
let message = log.message; | ||
let mut others = Vec::new(); | ||
// get attributes using a match | ||
for attr in &log.attributes { | ||
match attr.key.to_lowercase().as_str() { | ||
"level" | "lvl" | "severity" => level = Some(attr.value.clone()), | ||
_ => others.push(format!( | ||
"{}{}{}", | ||
attr.key.clone().magenta(), | ||
"=", | ||
attr.value | ||
.clone() | ||
.normal() | ||
.replace('"', "\"".dimmed().to_string().as_str()) | ||
)), | ||
} | ||
} | ||
// get the level and colour it | ||
let level = level | ||
.map(|level| { | ||
// make it uppercase so we dont have to make another variable | ||
// for some reason, .uppercase() removes formatting | ||
|
||
match level.replace('"', "").to_lowercase().as_str() { | ||
"info" => "[INFO]".blue(), | ||
"error" | "err" => "[ERRO]".red(), | ||
"warn" => "[WARN]".yellow(), | ||
"debug" => "[DBUG]".dimmed(), | ||
_ => format!("[{}]", level).normal(), | ||
} | ||
.bold() | ||
}) | ||
.unwrap(); | ||
println!( | ||
"{} {} {} {}", | ||
log.timestamp.replace('"', "").normal(), | ||
level, | ||
message, | ||
others.join(" ") | ||
); | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod logs; | ||
pub mod prompt; |