Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3512549
D13941.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13941.id.diff
View Options
diff --git a/services/backup/Cargo.toml b/services/backup/Cargo.toml
--- a/services/backup/Cargo.toml
+++ b/services/backup/Cargo.toml
@@ -26,7 +26,7 @@
tokio-stream = { workspace = true }
tracing = { workspace = true }
tracing-futures = { workspace = true, features = ["futures-03"] }
-tracing-subscriber = { workspace = true, features = ["env-filter"] }
+tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
uuid = { workspace = true, features = ["v4"] }
actix-web = { workspace = true }
tracing-actix-web = { workspace = true }
diff --git a/services/backup/src/constants.rs b/services/backup/src/constants.rs
--- a/services/backup/src/constants.rs
+++ b/services/backup/src/constants.rs
@@ -14,6 +14,7 @@
// Environment variable names
pub const LOG_LEVEL_ENV_VAR: &str =
tracing_subscriber::filter::EnvFilter::DEFAULT_ENV;
+pub const COMM_SERVICES_USE_JSON_LOGS: &str = "COMM_SERVICES_USE_JSON_LOGS";
// DynamoDB constants
pub mod backup_table {
diff --git a/services/backup/src/main.rs b/services/backup/src/main.rs
--- a/services/backup/src/main.rs
+++ b/services/backup/src/main.rs
@@ -1,5 +1,7 @@
use anyhow::Result;
use comm_lib::{auth::AuthService, blob::client::BlobServiceClient};
+use constants::COMM_SERVICES_USE_JSON_LOGS;
+use std::env;
use tracing::Level;
use tracing_subscriber::EnvFilter;
@@ -14,13 +16,27 @@
pub use config::CONFIG;
fn configure_logging() -> Result<()> {
+ let use_json_logs: bool = env::var(COMM_SERVICES_USE_JSON_LOGS)
+ .unwrap_or("false".to_string())
+ .parse()
+ .unwrap_or_default();
+
let filter = EnvFilter::builder()
.with_default_directive(Level::INFO.into())
.with_env_var(constants::LOG_LEVEL_ENV_VAR)
.from_env_lossy();
- let subscriber = tracing_subscriber::fmt().with_env_filter(filter).finish();
- tracing::subscriber::set_global_default(subscriber)?;
+ if use_json_logs {
+ let subscriber = tracing_subscriber::fmt()
+ .json()
+ .with_env_filter(filter)
+ .finish();
+ tracing::subscriber::set_global_default(subscriber)?;
+ } else {
+ let subscriber = tracing_subscriber::fmt().with_env_filter(filter).finish();
+ tracing::subscriber::set_global_default(subscriber)?;
+ }
+
Ok(())
}
diff --git a/services/terraform/remote/service_backup.tf b/services/terraform/remote/service_backup.tf
--- a/services/terraform/remote/service_backup.tf
+++ b/services/terraform/remote/service_backup.tf
@@ -47,6 +47,10 @@
{
name = "COMM_SERVICES_DISABLE_CSAT_VERIFICATION",
value = local.is_staging ? "false" : "true"
+ },
+ {
+ name = "COMM_SERVICES_USE_JSON_LOGS",
+ value = local.comm_services_use_json_logs
}
]
logConfiguration = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 8:27 PM (18 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692376
Default Alt Text
D13941.id.diff (2 KB)
Attached To
Mode
D13941: [backup/terraform] use json logs in backup if COMM_SERVICES_USE_JSON_LOGS variable set to true
Attached
Detach File
Event Timeline
Log In to Comment