4444// TODO(315772518) Re-enable once metrics send is reenabled
4545// #include "cuttlefish/host/commands/cvd/metrics/cvd_metrics_api.h"
4646
47+ extern char ** environ;
48+
4749namespace cuttlefish {
4850namespace {
4951
@@ -70,6 +72,16 @@ LogSeverity CvdVerbosityOption(cvd_common::Args& all_args) {
7072 return LogSeverity::Info;
7173 }
7274 LogSeverity verbosity = *to_severity_res;
75+ // Set environment variables to the requested verbosity for subcommands and
76+ // subprocesses to use.
77+ if (int res = setenv (kConsoleSeverityEnvVar , verbosity_flag_value.c_str (), 1 );
78+ res) {
79+ PLOG (ERROR) << " Failed to set console log severity environment variable" ;
80+ }
81+ if (int res = setenv (kFileSeverityEnvVar , verbosity_flag_value.c_str (), 1 );
82+ res) {
83+ PLOG (ERROR) << " Failed to set file log severity environment variable" ;
84+ }
7385 return verbosity;
7486}
7587
@@ -110,15 +122,15 @@ void IncreaseFileLimit() {
110122 }
111123}
112124
113- Result<void > CvdMain (cvd_common::Args all_args, char ** envp ) {
125+ Result<void > CvdMain (cvd_common::Args all_args) {
114126 if (!isatty (0 )) {
115127 LOG (INFO) << GetVersionIds ().ToString ();
116128 }
117129 CF_EXPECT (EnsureCvdDirectoriesExist ());
118130
119131 CF_EXPECT (!all_args.empty ());
120132
121- auto env = EnvpToMap (envp );
133+ auto env = EnvpToMap (environ );
122134 // TODO(315772518) Re-enable once metrics send is skipped in a env
123135 // without network support
124136 // CvdMetrics::SendCvdMetrics(all_args);
@@ -205,7 +217,7 @@ bool ValidateHostConfiguration() {
205217} // namespace
206218} // namespace cuttlefish
207219
208- int main (int argc, char ** argv, char ** envp ) {
220+ int main (int argc, char ** argv) {
209221 srand (time (NULL ));
210222
211223 cuttlefish::cvd_common::Args all_args = cuttlefish::ArgsToVec (argc, argv);
@@ -220,7 +232,7 @@ int main(int argc, char** argv, char** envp) {
220232 if (!cuttlefish::ValidateHostConfiguration ()) {
221233 return -1 ;
222234 }
223- auto result = cuttlefish::CvdMain (std::move (all_args), envp );
235+ auto result = cuttlefish::CvdMain (std::move (all_args));
224236 if (result.ok ()) {
225237 return 0 ;
226238 } else {
0 commit comments