(&self, record: &log::Record)
| 71 | } |
| 72 | |
| 73 | fn log(&self, record: &log::Record) { |
| 74 | if !should_provider_logger_handle_record(record) { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | let level = record.level(); |
| 79 | let message = record.args(); |
| 80 | |
| 81 | if let Some(group_event) = get_group_event(record) { |
| 82 | let now = SystemTime::now(); |
| 83 | let timestamp = now.duration_since(UNIX_EPOCH).unwrap().as_secs(); |
| 84 | let mut section_id = self.section_id.lock().unwrap(); |
| 85 | |
| 86 | match group_event { |
| 87 | GroupEvent::Start(name) | GroupEvent::StartOpened(name) => { |
| 88 | let new_section_id = GITLAB_SECTION_ID_SANITIZE_REGEX |
| 89 | .replace_all(&name, "_") |
| 90 | .to_ascii_lowercase(); |
| 91 | |
| 92 | *section_id = Some(new_section_id.to_string()); |
| 93 | |
| 94 | // https://docs.gitlab.com/ee/ci/yaml/script.html#custom-collapsible-sections |
| 95 | println!( |
| 96 | "{ERASE_CURSOR}section_start:{timestamp}:{new_section_id}{U_CR}{ERASE_CURSOR}{U_ESC}[36;1m{name}{COLOR_RESET}" |
| 97 | ); |
| 98 | } |
| 99 | GroupEvent::End => { |
| 100 | // do not fail if there is no current section |
| 101 | let current_section_id = section_id.clone().unwrap_or("".to_string()); |
| 102 | |
| 103 | // https://docs.gitlab.com/ee/ci/yaml/script.html#custom-collapsible-sections |
| 104 | println!( |
| 105 | "{ERASE_CURSOR}section_end:{timestamp}:{current_section_id}{U_CR}{ERASE_CURSOR}" |
| 106 | ); |
| 107 | |
| 108 | *section_id = None; |
| 109 | } |
| 110 | } |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | if let Some(announcement) = get_announcement_event(record) { |
| 115 | println!("{}", style(announcement).green()); |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | if get_json_event(record).is_some() { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | if level > self.log_level { |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | // set log colors. See https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#colors--graphics-mode |
| 128 | match level { |
| 129 | Level::Error => { |
| 130 | println!("{}", style(message).red()); |
nothing calls this directly
no test coverage detected