summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2009-11-05 20:26:24 (GMT)
committerandreas_kupries <akupries@shaw.ca>2009-11-05 20:26:24 (GMT)
commit6b92eaeb72848bb82826716a7a18f3291042db19 (patch)
treec9ca758e66b7afdc306f0a0321f7d05ddb68c639 /library
parentb977ee0d9d914e5cd1ab95214d34b7f950d4c331 (diff)
downloadtcl-6b92eaeb72848bb82826716a7a18f3291042db19.zip
tcl-6b92eaeb72848bb82826716a7a18f3291042db19.tar.gz
tcl-6b92eaeb72848bb82826716a7a18f3291042db19.tar.bz2
* library/safe.tcl: A series of patches which bring the SafeBase
up to date with code guidelines, Tcl's features, also eliminating a number of inefficiencies along the way. (9) Changed the log command setup so that logging is compiled out completely when disabled (default).
Diffstat (limited to 'library')
-rw-r--r--library/safe.tcl43
1 files changed, 29 insertions, 14 deletions
diff --git a/library/safe.tcl b/library/safe.tcl
index db4a41b..dc50e52 100644
--- a/library/safe.tcl
+++ b/library/safe.tcl
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: safe.tcl,v 1.27 2009/11/05 20:15:36 andreas_kupries Exp $
+# RCS: @(#) $Id: safe.tcl,v 1.28 2009/11/05 20:26:25 andreas_kupries Exp $
#
# The implementation is based on namespaces. These naming conventions are
@@ -542,13 +542,28 @@ proc ::safe::interpDelete {slave} {
proc ::safe::setLogCmd {args} {
variable Log
- if {[llength $args] == 0} {
+ set la [llength $args]
+ if {$la == 0} {
return $Log
- } elseif {[llength $args] == 1} {
+ } elseif {$la == 1} {
set Log [lindex $args 0]
} else {
set Log $args
}
+
+ if {$Log eq ""} {
+ # Disable logging completely. Calls to it will be compiled out
+ # of all users.
+ proc ::safe::Log {args} {}
+ } else {
+ # Activate logging, define proper command.
+
+ proc ::safe::Log {slave msg {type ERROR}} {
+ variable Log
+ {*}$Log "$type for slave $slave : $msg"
+ return
+ }
+ }
}
# ------------------- END OF PUBLIC METHODS ------------
@@ -617,17 +632,6 @@ proc ::safe::TranslatePath {slave path} {
return [string map $state(access_path,map) $path]
}
-
-# Log eventually log an error; to enable error logging, set Log to {puts
-# stderr} for instance
-proc ::safe::Log {slave msg {type ERROR}} {
- variable Log
- if {[info exists Log] && [llength $Log]} {
- {*}$Log "$type for slave $slave : $msg"
- }
-}
-
-
# file name control (limit access to files/resources that should be a
# valid tcl source file)
proc ::safe::CheckFileName {slave file} {
@@ -999,6 +1003,17 @@ proc ::safe::Setup {} {
# temp not needed anymore
::tcl::OptKeyDelete $temp
+ ####
+ #
+ # Default: No logging.
+ #
+ ####
+
+ setLogCmd {}
+
+ # Log eventually.
+ # To enable error logging, set Log to {puts stderr} for instance,
+ # via setLogCmd.
return
}