Page MenuHomePhabricator

D13452.diff
No OneTemporary

D13452.diff

diff --git a/services/terraform/remote/service_tunnelbroker.tf b/services/terraform/remote/service_tunnelbroker.tf
--- a/services/terraform/remote/service_tunnelbroker.tf
+++ b/services/terraform/remote/service_tunnelbroker.tf
@@ -106,6 +106,10 @@
{
name = "COMM_TUNNELBROKER_IDENTITY_ENDPOINT",
value = local.identity_local_url
+ },
+ {
+ name = "COMM_SERVICES_USE_JSON_LOGS",
+ value = local.comm_services_use_json_logs
}
]
secrets = [
diff --git a/services/tunnelbroker/Cargo.toml b/services/tunnelbroker/Cargo.toml
--- a/services/tunnelbroker/Cargo.toml
+++ b/services/tunnelbroker/Cargo.toml
@@ -24,7 +24,7 @@
tokio = { workspace = true, features = ["rt-multi-thread"] }
tonic = "0.8"
tracing = { workspace = true }
-tracing-subscriber = { workspace = true, features = ["env-filter"] }
+tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
tunnelbroker_messages = { path = "../../shared/tunnelbroker_messages" }
derive_more = { workspace = true }
lapin = { workspace = true }
diff --git a/services/tunnelbroker/src/constants.rs b/services/tunnelbroker/src/constants.rs
--- a/services/tunnelbroker/src/constants.rs
+++ b/services/tunnelbroker/src/constants.rs
@@ -16,6 +16,7 @@
pub const ENV_FCM_CONFIG: &str = "FCM_CONFIG";
pub const ENV_WEB_PUSH_CONFIG: &str = "WEB_PUSH_CONFIG";
pub const ENV_WNS_CONFIG: &str = "WNS_CONFIG";
+pub const COMM_SERVICES_USE_JSON_LOGS: &str = "COMM_SERVICES_USE_JSON_LOGS";
pub const LOG_LEVEL_ENV_VAR: &str =
tracing_subscriber::filter::EnvFilter::DEFAULT_ENV;
diff --git a/services/tunnelbroker/src/main.rs b/services/tunnelbroker/src/main.rs
--- a/services/tunnelbroker/src/main.rs
+++ b/services/tunnelbroker/src/main.rs
@@ -15,19 +15,35 @@
use crate::notifs::NotifClient;
use anyhow::{anyhow, Result};
use config::CONFIG;
+use constants::COMM_SERVICES_USE_JSON_LOGS;
+use std::env;
use tracing::{self, error, info, Level};
use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> 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)
- .expect("Unable to configure tracing");
+ if use_json_logs {
+ let subscriber = tracing_subscriber::fmt()
+ .json()
+ .with_env_filter(filter)
+ .finish();
+ tracing::subscriber::set_global_default(subscriber)
+ .expect("Unable to configure tracing");
+ } else {
+ let subscriber = tracing_subscriber::fmt().with_env_filter(filter).finish();
+ tracing::subscriber::set_global_default(subscriber)
+ .expect("Unable to configure tracing");
+ }
config::parse_cmdline_args()?;
let aws_config = config::load_aws_config().await;

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 10:56 AM (12 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690801
Default Alt Text
D13452.diff (3 KB)

Event Timeline