aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2016-10-18 11:11:48 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2016-10-18 11:11:48 -0400
commitd7d215acc4b2cb34f8d89fd29bdb6719ca98f7d3 (patch)
tree6cd654cab52c752ae3d3cdd8440986d4b73cc64c
parent96e7983bfe96b865fdb67e8d41ca5d4104f9261c (diff)
downloadGradeBook-d7d215acc4b2cb34f8d89fd29bdb6719ca98f7d3.tar.gz
GradeBook-d7d215acc4b2cb34f8d89fd29bdb6719ca98f7d3.zip
added the addLogEntry and redone dbg messaging
-rwxr-xr-xGradeBook_lib.tcl47
1 files changed, 38 insertions, 9 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 45866b9..41fa9f1 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -439,21 +439,50 @@ proc dbg {msg {category msg_level_critical} {location ""}} {
set location " in $location"
}
switch $category {
- msg_level_info {set msg_header "Info$location:"; set level 6}
- msg_level_warning {set msg_header "Warning$location:"; set level 4}
- msg_level_dbg {set msg_header "Debug$location:"; set level 3}
- msg_level_log {set msg_header "Log$location:"; set level 2}
- msg_level_critical {set msg_header "Error$location:"; set level 1}
- default {set msg_header "Unknown$location:"; set level 0}
+ msg_level_info {set msg_header "Info$location:";}
+ msg_level_warning {set msg_header "Warning$location:";}
+ msg_level_dbg {set msg_header "Debug$location:";}
+ msg_level_log {set msg_header "Log$location:";}
+ msg_level_critical {set msg_header "Error$location:";}
+ default {set msg_header "Unknown$location:";}
}
+ addLogEntry "dbg message level $msg_header" "$msg" "$category"
+}
+
+proc addLogEntry {entryTitle entryContent {category msg_level_critical}} {
+ global GradebookServerConfig
+ global logEntry
+
+ switch $category {
+ msg_level_info {set level 6}
+ msg_level_warning {set level 4}
+ msg_level_dbg {set level 3}
+ msg_level_log {set level 2}
+ msg_level_critical {set level 1}
+ default {set level 0}
+ }
if { $level <= $GradebookServerConfig(verbosity_level) } {
- set fid [open $GradebookServerConfig(log_file) a+]
- puts $fid "$msg_header $msg"
- close $fid
+ lappend logEntry "$entryTitle" [::json::write string "$entryContent"]
}
}
+proc logEntryToLogFile {} {
+ global logEntry
+
+ #::json::write indented false
+ set logEntryJsonString [json::write object {*}$logEntry]
+ rawTextToLogFile "$logEntryJsonString"
+}
+
+proc rawTextToLogFile {{msg "Error: message is not specified"}} {
+ global GradebookServerConfig
+
+ set fid [open $GradebookServerConfig(log_file) a+]
+ puts $fid "$msg"
+ close $fid
+}
+
proc timestamp { } {
return [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]
}