Skip to content

Commit bdfac71

Browse files
committed
turn off verbosity by default
also overrides verbosity value with env var `ACTIONS_STEP_DEBUG` as enabled for job re-runs with debug logs enabled.
1 parent 35bf99a commit bdfac71

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn get_arg_parser() -> Command {
1313
Arg::new("verbosity")
1414
.long("verbosity")
1515
.short('v')
16-
.default_value("debug")
16+
.default_value("info")
1717
.value_parser(["debug", "info"])
1818
.long_help(
1919
"This controls the action's verbosity in the workflow's logs.

src/rest_api/github_api.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ pub struct GithubApiClient {
3838

3939
/// The value of the `GITHUB_SHA` environment variable.
4040
sha: Option<String>,
41+
42+
/// The value of the `ACTIONS_STEP_DEBUG` environment variable.
43+
pub debug_enabled: bool,
4144
}
4245

4346
impl Default for GithubApiClient {
@@ -77,9 +80,15 @@ impl GithubApiClient {
7780
} else {
7881
None
7982
},
83+
debug_enabled: match env::var("ACTIONS_STEP_DEBUG") {
84+
Ok(val) => val == "true",
85+
Err(_) => false,
86+
},
8087
}
8188
}
8289
}
90+
91+
// implement the RestApiClient trait for the GithubApiClient
8392
impl RestApiClient for GithubApiClient {
8493
fn set_exit_code(
8594
&self,

src/run.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ pub fn main(args: Vec<String>) -> i32 {
3838
let args = arg_parser.get_matches_from(args);
3939

4040
logger::init().unwrap();
41-
let verbosity = args.get_one::<String>("verbosity").unwrap().as_str() == "debug";
42-
set_max_level(if verbosity {
43-
LevelFilter::Debug
44-
} else {
45-
LevelFilter::Info
46-
});
4741

4842
let root_path = args.get_one::<String>("repo-root").unwrap();
4943
if root_path != &String::from(".") {
@@ -61,6 +55,12 @@ pub fn main(args: Vec<String>) -> i32 {
6155
};
6256

6357
let rest_api_client = GithubApiClient::new();
58+
let verbosity = args.get_one::<String>("verbosity").unwrap().as_str() == "debug";
59+
set_max_level(if verbosity || rest_api_client.debug_enabled {
60+
LevelFilter::Debug
61+
} else {
62+
LevelFilter::Info
63+
});
6464
log::info!("Processing event {}", rest_api_client.event_name);
6565

6666
let extensions = args

0 commit comments

Comments
 (0)