| |
#[cfg(test)]
|
| |
static mut LOGGER: Option<Logger> = None;
|
| |
|
| - |
struct LogLevelFilter<D> {
|
| - |
drain: D,
|
| - |
minimum_log_level: Arc<Mutex<slog::Level>>,
|
| - |
}
|
| - |
|
| - |
impl<D> LogLevelFilter<D> {
|
| - |
pub fn new(drain: D, minimum_log_level: Arc<Mutex<slog::Level>>) -> Self {
|
| - |
Self {
|
| - |
drain,
|
| - |
minimum_log_level,
|
| - |
}
|
| - |
}
|
| - |
}
|
| - |
|
| - |
impl<D> Drain for LogLevelFilter<D>
|
| - |
where
|
| - |
D: Drain,
|
| - |
{
|
| - |
type Ok = Option<D::Ok>;
|
| - |
type Err = Option<D::Err>;
|
| - |
|
| - |
fn log(
|
| - |
&self,
|
| - |
record: &slog::Record,
|
| - |
values: &slog::OwnedKVList,
|
| - |
) -> Result<Self::Ok, Self::Err> {
|
| - |
#[allow(clippy::unwrap_used)] // We have no good way to report an error
|
| - |
let min = *self
|
| - |
.minimum_log_level
|
| - |
.lock()
|
| - |
.expect("lock log level filter minimum level");
|
| - |
if record.level().is_at_least(min) {
|
| - |
self.drain.log(record, values).map(Some).map_err(Some)
|
| - |
} else {
|
| - |
Ok(None)
|
| - |
}
|
| - |
}
|
| - |
}
|
| - |
|
| |
#[cfg(test)]
|
| |
#[ctor::ctor]
|
| |
fn open_for_tests() {
|
| |
INIT.call_once(|| unsafe {
|
| - |
LOGGER = Some(open());
|
| + |
LOGGER = Some(open(LogLevel::Trace));
|
| |
});
|
| |
}
|
| |
|
| |
pub fn start_cib() {
|
| - |
info!(slog_scope::logger(), "CI broker starts"; "version" => env!("GIT_HEAD"));
|
| + |
info!(version = env!("GIT_HEAD"), "CI broker starts");
|
| |
}
|
| |
|
| |
pub fn end_cib_successfully() {
|
| - |
info!(slog_scope::logger(), "CI broker ends successfully");
|
| + |
info!("CI broker ends successfully");
|
| |
}
|
| |
|
| |
pub fn end_cib_in_error() {
|
| - |
error!(
|
| - |
slog_scope::logger(),
|
| - |
"CI broker ends in unrecoverable error"
|
| - |
);
|
| + |
error!("CI broker ends in unrecoverable error");
|
| |
}
|
| |
|
| |
pub fn node_event_source_created(source: &NodeEventSource) {
|
| - |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"created node event source";
|
| - |
"source" => format!("{source:#?}")
|
| - |
);
|
| + |
debug!(source = format!("{source:#?}"), "created node event source");
|
| |
}
|
| |
|
| |
pub fn node_event_source_got_event(event: &Event) {
|
| |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"node event source received event";
|
| - |
"node_event" => format!("{event:#?}")
|
| + |
node_event = ?event,
|
| + |
"node event source received event"
|
| |
);
|
| |
}
|
| |
|
| |
pub fn node_event_source_eof(source: &NodeEventSource) {
|
| |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"node event source end of file on control socket";
|
| - |
"node_event_source" => format!("{source:#?}")
|
| + |
node_event_source = ?source,
|
| + |
"node event source end of file on control socket"
|
| |
);
|
| |
}
|
| |
|
| |
pub fn ci_event_source_created(source: &CiEventSource) {
|
| - |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"created CI event source";
|
| - |
"source" => format!("{source:#?}")
|
| - |
);
|
| + |
debug!(?source, "created CI event source");
|
| |
}
|
| |
|
| |
pub fn ci_event_source_got_events(events: &[CiEvent]) {
|
| - |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"CI event source received events";
|
| - |
"ci_events" => format!("{events:#?}")
|
| - |
);
|
| + |
debug!(?events, "CI event source received events");
|
| |
}
|
| |
|
| |
pub fn ci_event_source_disconnected() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"CI event source received disconnection"
|
| - |
);
|
| + |
info!("CI event source received disconnection");
|
| |
}
|
| |
|
| |
pub fn ci_event_source_end() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"CI event source was notified end of events"
|
| - |
);
|
| + |
info!("CI event source was notified end of events");
|
| |
}
|
| |
|
| |
pub fn ci_event_source_eof(source: &CiEventSource) {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"CI event source end of file";
|
| - |
"ci_event_source" => format!("{source:#?}")
|
| - |
);
|
| + |
info!(?source, "CI event source end of file");
|
| |
}
|
| |
|
| |
pub fn loaded_config(config: &Config) {
|
| - |
debug!(slog_scope::logger(), "loaded configuration {config:#?}");
|
| + |
debug!("loaded configuration {config:#?}");
|
| |
}
|
| |
|
| |
pub fn adapter_config(config: &Config) {
|
| - |
debug!(slog_scope::logger(), "adapter configuration {config:#?}");
|
| + |
debug!("adapter configuration {config:#?}");
|
| |
}
|
| |
|
| |
pub fn queueproc_start() {
|
| - |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"start thread to process events until a shutdown event"
|
| - |
);
|
| + |
debug!("start thread to process events until a shutdown event");
|
| |
}
|
| |
|
| |
pub fn queueproc_end() {
|
| - |
debug!(slog_scope::logger(), "thread to process events ends");
|
| + |
debug!("thread to process events ends");
|
| |
}
|
| |
|
| |
pub fn queueproc_channel_disconnect() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"event notification channel disconnected"
|
| - |
);
|
| + |
info!("event notification channel disconnected");
|
| |
}
|
| |
|
| |
pub fn queueproc_queue_length(len: usize) {
|
| - |
trace!(
|
| - |
slog_scope::logger(),
|
| - |
"event queue length"; "length" => len);
|
| + |
trace!(?len, "event queue length");
|
| |
}
|
| |
|
| |
pub fn queueproc_picked_event(id: &QueueId, event: &QueuedCiEvent) {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"picked event from queue: {id}: {event:#?}"
|
| - |
);
|
| + |
info!("picked event from queue: {id}: {event:#?}");
|
| |
}
|
| |
|
| |
pub fn queueproc_remove_event(id: &QueueId) {
|
| - |
info!(slog_scope::logger(), "remove event from queue: {id}");
|
| + |
info!("remove event from queue: {id}");
|
| |
}
|
| |
|
| |
pub fn queueproc_action_run(rid: &RepoId, oid: &Oid) {
|
| - |
info!(slog_scope::logger(), "Action: run: {rid} {oid}");
|
| + |
info!("Action: run: {rid} {oid}");
|
| |
}
|
| |
|
| |
pub fn queueproc_action_shutdown() {
|
| - |
info!(slog_scope::logger(), "Action: shutdown");
|
| + |
info!("Action: shutdown");
|
| |
}
|
| |
|
| |
pub fn queueadd_start() {
|
| - |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"start thread to add events from node to event queue"
|
| - |
);
|
| + |
debug!("start thread to add events from node to event queue");
|
| |
}
|
| |
|
| |
pub fn queueadd_control_socket_close() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"no more events from node control socket"
|
| - |
);
|
| + |
info!("no more events from node control socket");
|
| |
}
|
| |
|
| |
pub fn queueadd_push_event(e: &CiEvent) {
|
| - |
debug!(
|
| - |
slog_scope::logger(),
|
| - |
"insert broker event into queue: {e:?}"
|
| - |
);
|
| + |
debug!("insert broker event into queue: {e:?}");
|
| |
}
|
| |
|
| |
pub fn queueadd_end() {
|
| - |
debug!(slog_scope::logger(), "thread to process events ends");
|
| + |
debug!("thread to process events ends");
|
| |
}
|
| |
|
| |
pub fn pages_directory_unset() {
|
| - |
warn!(
|
| - |
slog_scope::logger(),
|
| - |
"not writing HTML report pages as output directory has not been set"
|
| - |
);
|
| + |
warn!("not writing HTML report pages as output directory has not been set");
|
| |
}
|
| |
|
| |
pub fn pages_interval(interval: Duration) {
|
| |
debug!(
|
| - |
slog_scope::logger(),
|
| |
"wait about {} seconds to update HTML report pages again",
|
| |
interval.as_secs()
|
| |
);
|
| |
}
|
| |
|
| |
pub fn pages_disconnected() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"page updater: run notification channel disconnected"
|
| - |
);
|
| + |
info!("page updater: run notification channel disconnected");
|
| |
}
|
| |
|
| |
pub fn pages_start() {
|
| - |
debug!(slog_scope::logger(), "start page updater thread");
|
| + |
debug!("start page updater thread");
|
| |
}
|
| |
|
| |
pub fn pages_end() {
|
| - |
debug!(slog_scope::logger(), "end page updater thread");
|
| + |
debug!("end page updater thread");
|
| |
}
|
| |
|
| |
pub fn event_disconnected() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"connection to node control socket broke"
|
| - |
);
|
| + |
info!("connection to node control socket broke");
|
| |
}
|
| |
|
| |
pub fn event_end() {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"no more node events from control socket: iterator ended"
|
| - |
);
|
| + |
info!("no more node events from control socket: iterator ended");
|
| |
}
|
| |
|
| |
pub fn broker_db(filename: &Path) {
|
| - |
info!(
|
| - |
slog_scope::logger(),
|
| - |
"broker database: {}",
|
| - |
filename.display()
|
| - |
);
|
| + |
info!("broker database: {}", filename.display());
|
| |
}
|
| |
|
| |
pub fn broker_start_run(trigger: &Request) {
|
| - |
info!(slog_scope::logger(), "start CI run");
|
| - |
debug!(slog_scope::logger(), "trigger event: {trigger:#?}");
|
| + |
info!("start CI run");
|
| + |
debug!("trigger event: {trigger:#?}");
|
| |
}
|
| |
|
| |
pub fn broker_end_run(run: &Run) {
|
| - |
info!(slog_scope::logger(), "Finish CI run");
|
| - |
debug!(slog_scope::logger(), "finished CI run: {run:#?}");
|
| + |
info!("Finish CI run");
|
| + |
debug!("finished CI run: {run:#?}");
|
| |
}
|
| |
|
| |
pub fn adapter_no_first_response() {
|
| - |
error!(slog_scope::logger(), "no first response message");
|
| + |
error!("no first response message");
|
| |
}
|
| |
|
| |
pub fn adapter_no_second_response() {
|
| - |
error!(slog_scope::logger(), "no second response message");
|
| + |
error!("no second response message");
|
| |
}
|
| |
|
| |
pub fn adapter_too_many_responses() {
|
| - |
error!(slog_scope::logger(), "too many response messages");
|
| + |
error!("too many response messages");
|
| |
}
|
| |
|
| |
pub fn adapter_stderr_line(line: &str) {
|
| - |
debug!(slog_scope::logger(), "adapter stderr"; "stderr" => line);
|
| + |
debug!(stderr_line = line, "adapter stderr");
|
| |
}
|
| |
|
| |
pub fn adapter_result(exit: i32) {
|
| - |
debug!(slog_scope::logger(), "adapter exit code"; "exit_code" => exit);
|
| + |
debug!(exit_code = exit, "adapter exit code");
|
| |
}
|
| |
|
| |
pub fn adapter_did_not_exit_voluntarily() {
|
| - |
warn!(
|
| - |
slog_scope::logger(),
|
| - |
"adapter did not exit voluntarily: terminated for taking too long"
|
| - |
);
|
| + |
warn!("adapter did not exit voluntarily: terminated for taking too long");
|
| |
}
|
| |
|
| |
pub fn adapter_did_not_exit() {
|
| - |
warn!(
|
| - |
slog_scope::logger(),
|
| - |
"adapter did not exit: probably killed by signal"
|
| - |
);
|
| + |
warn!("adapter did not exit: probably killed by signal");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_request_termination(result: Result<(), std::sync::mpsc::SendError<()>>) {
|
| - |
trace!(
|
| - |
slog_scope::logger(),
|
| - |
"request termination of child process: {result:?}"
|
| - |
);
|
| + |
trace!("request termination of child process: {result:?}");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_word_from_nanny() {
|
| - |
trace!(slog_scope::logger(), "wait: wait for word from nanny");
|
| + |
trace!("wait: wait for word from nanny");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_got_word_from_nanny() {
|
| - |
trace!(slog_scope::logger(), "got word from nanny");
|
| + |
trace!("got word from nanny");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_on_nanny_to_end() {
|
| - |
trace!(slog_scope::logger(), "wait: wait on nanny thread to end");
|
| + |
trace!("wait: wait on nanny thread to end");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_on_stdin_writer_to_end() {
|
| - |
trace!(
|
| - |
slog_scope::logger(),
|
| - |
"wait: wait for stdin writer to terminate"
|
| - |
);
|
| + |
trace!("wait: wait for stdin writer to terminate");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_on_stdout_reader_to_end() {
|
| - |
trace!(
|
| - |
slog_scope::logger(),
|
| - |
"wait: wait for stdout reader to terminate"
|
| - |
);
|
| + |
trace!("wait: wait for stdout reader to terminate");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_on_stderr_reader_to_end() {
|
| - |
trace!(
|
| - |
slog_scope::logger(),
|
| - |
"wait: wait for stderr reader to terminate"
|
| - |
);
|
| + |
trace!("wait: wait for stderr reader to terminate");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_on_child_to_end() {
|
| - |
trace!(slog_scope::logger(), "wait: wait for child to terminate");
|
| + |
trace!("wait: wait for child to terminate");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_wait_status(status: ExitStatus) {
|
| - |
trace!(slog_scope::logger(), "wait: wait status: {status:?}");
|
| + |
trace!("wait: wait status: {status:?}");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_ok() {
|
| - |
trace!(slog_scope::logger(), "wait: return Ok result");
|
| + |
trace!("wait: return Ok result");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_nanny_start() {
|
| - |
trace!(slog_scope::logger(), "nanny: start monitoring child");
|
| + |
trace!("nanny: start monitoring child");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_nanny_terminated_as_requested(result: Result<(), std::io::Error>) {
|
| - |
trace!(
|
| - |
slog_scope::logger(),
|
| - |
"nanny: terminated child by request: {result:?}"
|
| - |
);
|
| + |
trace!("nanny: terminated child by request: {result:?}");
|
| |
}
|
| |
|
| |
pub fn timeoutcmd_nanny_too_long(
|