From 99f9a005b8bf7916e9dbb382e307ba71a2aabc0c Mon Sep 17 00:00:00 2001 From: Martin Elff Date: Thu, 14 Nov 2024 22:17:24 +0100 Subject: [PATCH] Code cleanup (remove logging) --- pkg/R/help.R | 2 +- pkg/R/kernel.R | 26 +++++++++++++------------- pkg/R/output.R | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/R/help.R b/pkg/R/help.R index b6a6734..e119ac2 100644 --- a/pkg/R/help.R +++ b/pkg/R/help.R @@ -358,7 +358,7 @@ my_example2html <- function(topic, package, Rhome = "", env = NULL){ } example_html <- function(topic,package = NULL,...) { - log_out("====== example_html ======") + # log_out("====== example_html ======") e <- capture.output(example(topic,package,local=TRUE, character.only=TRUE)) diff --git a/pkg/R/kernel.R b/pkg/R/kernel.R index cb8f142..4abc8b8 100644 --- a/pkg/R/kernel.R +++ b/pkg/R/kernel.R @@ -88,7 +88,7 @@ Kernel <- R6Class("Kernel", #' Run the kernel. run = function(){ self$start() - log_out("*** RKernel started ***") + # log_out("*** RKernel started ***") continue <- TRUE while(continue) { continue <- self$poll_and_respond() @@ -308,7 +308,7 @@ Kernel <- R6Class("Kernel", error = function(e) structure("errored", message = conditionMessage(e)), # ,traceback=.traceback()), interrupt = function(e) "interrupted") - log_out(d,use.str=TRUE) + # log_out(d,use.str=TRUE) if(is.character(d)) self$stderr(attr(d,"message")) else if(inherits(d,"display_data")){ @@ -808,7 +808,7 @@ Kernel <- R6Class("Kernel", private$graphics_client$start() }, r_display_changed_graphics = function() {display - log_out("r_display_changed_graphics") + # log_out("r_display_changed_graphics") d <- private$graphics_client$display_changed() if(length(d)) { msg <- list(type = class(d), @@ -826,20 +826,20 @@ Kernel <- R6Class("Kernel", r_msg_incomplete = FALSE, r_msg_frag = "", handle_r_stdout = function(text){ - log_out("=========================================================") - log_out("handle_r_stdout") + # log_out("=========================================================") + # log_out("handle_r_stdout") if (grepl(DLE, text)) { - log_out("DLE found") + # log_out("DLE found") text <- split_string1(text, DLE) } for(chunk in text){ if(!length(chunk) || !nzchar(chunk)) next - log_out(chunk, use.str = TRUE) + # log_out(chunk, use.str = TRUE) if (startsWith(chunk, MSG_BEGIN)) { - log_out("MSG_BEGIN found") + # log_out("MSG_BEGIN found") # log_out(chunk, use.print = TRUE) if (endsWith(chunk, MSG_END)) { - log_out("MSG_END found") + # log_out("MSG_END found") msg <- remove_prefix(chunk, MSG_BEGIN) |> remove_suffix(MSG_END) msg <- msg_unwrap(msg) # log_out(msg, use.print = FALSE) @@ -850,7 +850,7 @@ Kernel <- R6Class("Kernel", } } else if(endsWith(chunk, MSG_END)){ - log_out("MSG_END found") + # log_out("MSG_END found") # log_out(chunk, use.print = TRUE) msg <- paste0(private$r_msg_frag, remove_suffix(chunk, MSG_END)) private$r_msg_incomplete <- FALSE @@ -860,7 +860,7 @@ Kernel <- R6Class("Kernel", } else { if(private$r_msg_incomplete) { - log_out("incomplete chunk ...") + # log_out("incomplete chunk ...") private$r_msg_frag <- paste0(private$r_msg_frag, chunk) } else if(nzchar(chunk)) { @@ -869,7 +869,7 @@ Kernel <- R6Class("Kernel", } } private$r_display_changed_graphics() - log_out("----------------------------------------------") + # log_out("----------------------------------------------") } # log_out("handle_r_stdout done") }, @@ -894,7 +894,7 @@ Kernel <- R6Class("Kernel", msg_handler(msg) } else { log_error(sprintf("R session sent message of unknown type '%s'", msg_type)) - log_out(msg_handler, use.str = TRUE) + # log_out(msg_handler, use.str = TRUE) self$stderr(sprintf("R session sent message of unknown type '%s'", msg_type)) } }, diff --git a/pkg/R/output.R b/pkg/R/output.R index 73e4e2d..c29bd53 100644 --- a/pkg/R/output.R +++ b/pkg/R/output.R @@ -38,7 +38,7 @@ cat_with_hooks <- function (..., file = "", sep = " ", fill = FALSE, labels = N print_orig <- getFromNamespace("print","base") print_with_hooks <- function(x,...){ - log_out("print_with_hooks") + # log_out("print_with_hooks") run_output_hooks() if(any(class(x) %in% getOption("rkernel_displayed_classes"))) display(x)