Skip to content

Commit

Permalink
Code cleanup (remove logging)
Browse files Browse the repository at this point in the history
  • Loading branch information
melff committed Nov 14, 2024
1 parent 02eec73 commit 99f9a00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/R/help.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
26 changes: 13 additions & 13 deletions pkg/R/kernel.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")){
Expand Down Expand Up @@ -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),
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)) {
Expand All @@ -869,7 +869,7 @@ Kernel <- R6Class("Kernel",
}
}
private$r_display_changed_graphics()
log_out("----------------------------------------------")
# log_out("----------------------------------------------")
}
# log_out("handle_r_stdout done")
},
Expand All @@ -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))
}
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 99f9a00

Please sign in to comment.