Fossil SCM

Started to restructure the namespace hierarchy, beginning at the bottom, with the log module.

aku 2007-09-09 00:58 trunk
Commit 86a7f249c1f950d84dbfe93ec3acaa7715519f49
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -40,12 +40,12 @@
4040
4141
# -----------------------------------------------------------------------------
4242
# Requirements
4343
4444
package require Tcl 8.4
45
-package require tools::log ; # User Feedback
46
-package require import::cvs ; # Importer Control
45
+package require vc::tools::log ; # User Feedback
46
+package require import::cvs ; # Importer Control
4747
4848
# -----------------------------------------------------------------------------
4949
5050
proc main {} {
5151
commandline -> cvs fossil
@@ -65,11 +65,11 @@
6565
while {[string match "-*" [set opt [this]]]} {
6666
switch -exact -- $opt {
6767
--nosign { import::cvs::configure -nosign 1 }
6868
--debugcommit { import::cvs::configure -debugcommit 1 }
6969
--stopat { next ; import::cvs::configure -stopat [this] }
70
- -v { incr verbosity ; ::tools::log::verbosity $verbosity }
70
+ -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
7171
default usage
7272
}
7373
next
7474
}
7575
7676
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -40,12 +40,12 @@
40
41 # -----------------------------------------------------------------------------
42 # Requirements
43
44 package require Tcl 8.4
45 package require tools::log ; # User Feedback
46 package require import::cvs ; # Importer Control
47
48 # -----------------------------------------------------------------------------
49
50 proc main {} {
51 commandline -> cvs fossil
@@ -65,11 +65,11 @@
65 while {[string match "-*" [set opt [this]]]} {
66 switch -exact -- $opt {
67 --nosign { import::cvs::configure -nosign 1 }
68 --debugcommit { import::cvs::configure -debugcommit 1 }
69 --stopat { next ; import::cvs::configure -stopat [this] }
70 -v { incr verbosity ; ::tools::log::verbosity $verbosity }
71 default usage
72 }
73 next
74 }
75
76
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -40,12 +40,12 @@
40
41 # -----------------------------------------------------------------------------
42 # Requirements
43
44 package require Tcl 8.4
45 package require vc::tools::log ; # User Feedback
46 package require import::cvs ; # Importer Control
47
48 # -----------------------------------------------------------------------------
49
50 proc main {} {
51 commandline -> cvs fossil
@@ -65,11 +65,11 @@
65 while {[string match "-*" [set opt [this]]]} {
66 switch -exact -- $opt {
67 --nosign { import::cvs::configure -nosign 1 }
68 --debugcommit { import::cvs::configure -debugcommit 1 }
69 --stopat { next ; import::cvs::configure -stopat [this] }
70 -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
71 default usage
72 }
73 next
74 }
75
76
--- tools/lib/cvs.tcl
+++ tools/lib/cvs.tcl
@@ -3,18 +3,18 @@
33
44
# -----------------------------------------------------------------------------
55
# Requirements
66
77
package require Tcl 8.4
8
-package require fileutil ; # Tcllib (traverse directory hierarchy)
9
-package require rcsparser ; # Handling the RCS archive files.
10
-package require tools::log ; # User feedback
8
+package require fileutil ; # Tcllib (traverse directory hierarchy)
9
+package require rcsparser ; # Handling the RCS archive files.
10
+package require vc::tools::log ; # User feedback
1111
package require struct::tree
1212
1313
namespace eval ::cvs {
14
- tools::log::system cvs
15
- namespace import ::tools::log::write
14
+ vc::tools::log::system cvs
15
+ namespace import ::vc::tools::log::write
1616
}
1717
1818
# -----------------------------------------------------------------------------
1919
# API
2020
2121
--- tools/lib/cvs.tcl
+++ tools/lib/cvs.tcl
@@ -3,18 +3,18 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 package require fileutil ; # Tcllib (traverse directory hierarchy)
9 package require rcsparser ; # Handling the RCS archive files.
10 package require tools::log ; # User feedback
11 package require struct::tree
12
13 namespace eval ::cvs {
14 tools::log::system cvs
15 namespace import ::tools::log::write
16 }
17
18 # -----------------------------------------------------------------------------
19 # API
20
21
--- tools/lib/cvs.tcl
+++ tools/lib/cvs.tcl
@@ -3,18 +3,18 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 package require fileutil ; # Tcllib (traverse directory hierarchy)
9 package require rcsparser ; # Handling the RCS archive files.
10 package require vc::tools::log ; # User feedback
11 package require struct::tree
12
13 namespace eval ::cvs {
14 vc::tools::log::system cvs
15 namespace import ::vc::tools::log::write
16 }
17
18 # -----------------------------------------------------------------------------
19 # API
20
21
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -3,15 +3,15 @@
33
44
# -----------------------------------------------------------------------------
55
# Requirements
66
77
package require Tcl 8.4
8
-package require tools::log ; # User feedback
8
+package require vc::tools::log ; # User feedback
99
1010
namespace eval ::fossil {
11
- tools::log::system fossil
12
- namespace import ::tools::log::write
11
+ vc::tools::log::system fossil
12
+ namespace import ::vc::tools::log::write
1313
}
1414
1515
# -----------------------------------------------------------------------------
1616
# API
1717
1818
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -3,15 +3,15 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 package require tools::log ; # User feedback
9
10 namespace eval ::fossil {
11 tools::log::system fossil
12 namespace import ::tools::log::write
13 }
14
15 # -----------------------------------------------------------------------------
16 # API
17
18
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -3,15 +3,15 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 package require vc::tools::log ; # User feedback
9
10 namespace eval ::fossil {
11 vc::tools::log::system fossil
12 namespace import ::vc::tools::log::write
13 }
14
15 # -----------------------------------------------------------------------------
16 # API
17
18
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -3,17 +3,17 @@
33
44
# -----------------------------------------------------------------------------
55
# Requirements
66
77
package require Tcl 8.4
8
-package require cvs ; # Frontend, reading from source repository
9
-package require fossil ; # Backend, writing to destination repository.
10
-package require tools::log ; # User feedback
8
+package require cvs ; # Frontend, reading from source repository
9
+package require fossil ; # Backend, writing to destination repository.
10
+package require vc::tools::log ; # User feedback
1111
1212
namespace eval ::import::cvs {
13
- tools::log::system import
14
- namespace import ::tools::log::write
13
+ vc::tools::log::system import
14
+ namespace import ::vc::tools::log::write
1515
}
1616
1717
# -----------------------------------------------------------------------------
1818
# API
1919
@@ -83,11 +83,11 @@
8383
8484
set ntrunk [cvs::ntrunk] ; set ntfmt %[string length $ntrunk]s
8585
set nmax [cvs::ncsets] ; set nmfmt %[string length $nmax]s
8686
8787
cvs::foreach_cset cset [cvs::root] {
88
- ::tools::log::write 0 import "ChangeSet [format $nmfmt $cset] @ [format $ntfmt $nto]/$ntrunk ([format %6.2f [expr {$nto*100.0/$ntrunk}]]%)"
88
+ ::vc::tools::log::write 0 import "ChangeSet [format $nmfmt $cset] @ [format $ntfmt $nto]/$ntrunk ([format %6.2f [expr {$nto*100.0/$ntrunk}]]%)"
8989
Statistics [OneChangeSet $cset]
9090
}
9191
9292
write 0 import "========= [string repeat = 61]"
9393
write 0 import "Imported $nto [expr {($nto == 1) ? "changeset" : "changesets"}]"
@@ -115,14 +115,14 @@
115115
set tot [expr {$tot + $sec}]
116116
set avg [expr {$tot/$nto}]
117117
set max [expr {$ntrunk * $avg}]
118118
set rem [expr {$max - $tot}]
119119
120
- ::tools::log::write 3 import "st avg [format %.2f $avg] sec"
121
- ::tools::log::write 3 import "st run [format %7.2f $tot] sec [format %6.2f [expr {$tot/60}]] min [format %5.2f [expr {$tot/3600}]] hr"
122
- ::tools::log::write 3 import "st end [format %7.2f $max] sec [format %6.2f [expr {$max/60}]] min [format %5.2f [expr {$max/3600}]] hr"
123
- ::tools::log::write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
120
+ ::vc::tools::log::write 3 import "st avg [format %.2f $avg] sec"
121
+ ::vc::tools::log::write 3 import "st run [format %7.2f $tot] sec [format %6.2f [expr {$tot/60}]] min [format %5.2f [expr {$tot/3600}]] hr"
122
+ ::vc::tools::log::write 3 import "st end [format %7.2f $max] sec [format %6.2f [expr {$max/60}]] min [format %5.2f [expr {$max/3600}]] hr"
123
+ ::vc::tools::log::write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
124124
return
125125
}
126126
127127
proc ::import::cvs::OneChangeSet {cset} {
128128
variable nosign
@@ -143,12 +143,12 @@
143143
} 1] 0]
144144
cvs::uuid $cset $uuid
145145
146146
set sec [expr {$usec/1e6}]
147147
148
- ::tools::log::write 2 import "== $uuid +${ad}-${rm}*${ch}"
149
- ::tools::log::write 2 import "st in [format %.2f $sec] sec"
148
+ ::vc::tools::log::write 2 import "== $uuid +${ad}-${rm}*${ch}"
149
+ ::vc::tools::log::write 2 import "st in [format %.2f $sec] sec"
150150
151151
return $sec
152152
}
153153
154154
# -----------------------------------------------------------------------------
155155
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -3,17 +3,17 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 package require cvs ; # Frontend, reading from source repository
9 package require fossil ; # Backend, writing to destination repository.
10 package require tools::log ; # User feedback
11
12 namespace eval ::import::cvs {
13 tools::log::system import
14 namespace import ::tools::log::write
15 }
16
17 # -----------------------------------------------------------------------------
18 # API
19
@@ -83,11 +83,11 @@
83
84 set ntrunk [cvs::ntrunk] ; set ntfmt %[string length $ntrunk]s
85 set nmax [cvs::ncsets] ; set nmfmt %[string length $nmax]s
86
87 cvs::foreach_cset cset [cvs::root] {
88 ::tools::log::write 0 import "ChangeSet [format $nmfmt $cset] @ [format $ntfmt $nto]/$ntrunk ([format %6.2f [expr {$nto*100.0/$ntrunk}]]%)"
89 Statistics [OneChangeSet $cset]
90 }
91
92 write 0 import "========= [string repeat = 61]"
93 write 0 import "Imported $nto [expr {($nto == 1) ? "changeset" : "changesets"}]"
@@ -115,14 +115,14 @@
115 set tot [expr {$tot + $sec}]
116 set avg [expr {$tot/$nto}]
117 set max [expr {$ntrunk * $avg}]
118 set rem [expr {$max - $tot}]
119
120 ::tools::log::write 3 import "st avg [format %.2f $avg] sec"
121 ::tools::log::write 3 import "st run [format %7.2f $tot] sec [format %6.2f [expr {$tot/60}]] min [format %5.2f [expr {$tot/3600}]] hr"
122 ::tools::log::write 3 import "st end [format %7.2f $max] sec [format %6.2f [expr {$max/60}]] min [format %5.2f [expr {$max/3600}]] hr"
123 ::tools::log::write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
124 return
125 }
126
127 proc ::import::cvs::OneChangeSet {cset} {
128 variable nosign
@@ -143,12 +143,12 @@
143 } 1] 0]
144 cvs::uuid $cset $uuid
145
146 set sec [expr {$usec/1e6}]
147
148 ::tools::log::write 2 import "== $uuid +${ad}-${rm}*${ch}"
149 ::tools::log::write 2 import "st in [format %.2f $sec] sec"
150
151 return $sec
152 }
153
154 # -----------------------------------------------------------------------------
155
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -3,17 +3,17 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 package require cvs ; # Frontend, reading from source repository
9 package require fossil ; # Backend, writing to destination repository.
10 package require vc::tools::log ; # User feedback
11
12 namespace eval ::import::cvs {
13 vc::tools::log::system import
14 namespace import ::vc::tools::log::write
15 }
16
17 # -----------------------------------------------------------------------------
18 # API
19
@@ -83,11 +83,11 @@
83
84 set ntrunk [cvs::ntrunk] ; set ntfmt %[string length $ntrunk]s
85 set nmax [cvs::ncsets] ; set nmfmt %[string length $nmax]s
86
87 cvs::foreach_cset cset [cvs::root] {
88 ::vc::tools::log::write 0 import "ChangeSet [format $nmfmt $cset] @ [format $ntfmt $nto]/$ntrunk ([format %6.2f [expr {$nto*100.0/$ntrunk}]]%)"
89 Statistics [OneChangeSet $cset]
90 }
91
92 write 0 import "========= [string repeat = 61]"
93 write 0 import "Imported $nto [expr {($nto == 1) ? "changeset" : "changesets"}]"
@@ -115,14 +115,14 @@
115 set tot [expr {$tot + $sec}]
116 set avg [expr {$tot/$nto}]
117 set max [expr {$ntrunk * $avg}]
118 set rem [expr {$max - $tot}]
119
120 ::vc::tools::log::write 3 import "st avg [format %.2f $avg] sec"
121 ::vc::tools::log::write 3 import "st run [format %7.2f $tot] sec [format %6.2f [expr {$tot/60}]] min [format %5.2f [expr {$tot/3600}]] hr"
122 ::vc::tools::log::write 3 import "st end [format %7.2f $max] sec [format %6.2f [expr {$max/60}]] min [format %5.2f [expr {$max/3600}]] hr"
123 ::vc::tools::log::write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
124 return
125 }
126
127 proc ::import::cvs::OneChangeSet {cset} {
128 variable nosign
@@ -143,12 +143,12 @@
143 } 1] 0]
144 cvs::uuid $cset $uuid
145
146 set sec [expr {$usec/1e6}]
147
148 ::vc::tools::log::write 2 import "== $uuid +${ad}-${rm}*${ch}"
149 ::vc::tools::log::write 2 import "st in [format %.2f $sec] sec"
150
151 return $sec
152 }
153
154 # -----------------------------------------------------------------------------
155
+24 -24
--- tools/lib/log.tcl
+++ tools/lib/log.tcl
@@ -3,26 +3,26 @@
33
44
# -----------------------------------------------------------------------------
55
# Requirements
66
77
package require Tcl 8.4
8
-namespace eval ::tools::log {}
8
+namespace eval ::vc::tools::log {}
99
1010
# -----------------------------------------------------------------------------
1111
# API
1212
1313
# Feedback generation.
1414
#
15
-# tools::log::write verbosity system text - Write message to the log.
16
-# tools::log::progress verbosity system n max - Drive a progress display.
15
+# vc::tools::log::write verbosity system text - Write message to the log.
16
+# vc::tools::log::progress verbosity system n max - Drive a progress display.
1717
1818
# Administrative operations.
1919
#
20
-# tools::log::verbosity level - Set the verbosity level of the application.
21
-# tools::log::verbosity? - Query the verbosity level of the application.
22
-# tools::log::setCmd cmdprefix - Set callback for output
23
-# tools::log::system name - Register a system (enables tabular log formatting).
20
+# vc::tools::log::verbosity level - Set the verbosity level of the application.
21
+# vc::tools::log::verbosity? - Query the verbosity level of the application.
22
+# vc::tools::log::setCmd cmdprefix - Set callback for output
23
+# vc::tools::log::system name - Register a system (enables tabular log formatting).
2424
2525
# Callback API ( Executed at the global level).
2626
#
2727
# cmdprefix 'write' system text
2828
# cmdprefix 'progress' system n max
@@ -34,11 +34,11 @@
3434
3535
# Write the message 'text' to log, for the named 'system'. The message
3636
# is written if and only if the message verbosity is less or equal the
3737
# chosen verbosity. A message of verbosity 0 cannot be blocked.
3838
39
-proc ::tools::log::write {verbosity system text} {
39
+proc ::vc::tools::log::write {verbosity system text} {
4040
variable loglevel
4141
variable logcmd
4242
variable sysfmt
4343
if {$verbosity > $loglevel} return
4444
uplevel #0 [linsert $logcmd end write [format $sysfmt $system] $text]
@@ -47,11 +47,11 @@
4747
4848
# Similar to write, especially in the handling of the verbosity, to
4949
# drive progress displays. It signals that for some long running
5050
# operation we are at tick 'n' of at most 'max' ticks.
5151
52
-proc ::tools::log::progress {verbosity system n max} {
52
+proc ::vc::tools::log::progress {verbosity system n max} {
5353
variable loglevel
5454
variable logcmd
5555
variable sysfmt
5656
if {$verbosity > $loglevel} return
5757
uplevel #0 [linsert $logcmd end progress [format $sysfmt $system] $n $max]
@@ -62,38 +62,38 @@
6262
# API Implementation - Administrative operations.
6363
6464
# Set verbosity to the chosen 'level'. Only messages with a level less
6565
# or equal to this one will be shown.
6666
67
-proc ::tools::log::verbosity {level} {
67
+proc ::vc::tools::log::verbosity {level} {
6868
variable loglevel
6969
if {$level < 1} {set level 0}
7070
set loglevel $level
7171
return
7272
}
7373
7474
# Query the currently set verbosity.
7575
76
-proc ::tools::log::verbosity? {} {
76
+proc ::vc::tools::log::verbosity? {} {
7777
variable loglevel
7878
return $loglevel
7979
}
8080
8181
# Set the log callback handling the actual output of messages going
8282
# through the package.
8383
84
-proc ::tools::log::setCmd {cmdprefix} {
84
+proc ::vc::tools::log::setCmd {cmdprefix} {
8585
variable logcmd $cmdprefix
8686
return
8787
}
8888
8989
# Register a system name, to enable tabular formatting. This is done
9090
# by setting up a format specifier with a proper width. This is
9191
# handled in the generation command, before the output callback is
9292
# invoked.
9393
94
-proc ::tools::log::system {name} {
94
+proc ::vc::tools::log::system {name} {
9595
variable sysfmt
9696
variable syslen
9797
9898
set nlen [string length $name]
9999
if {$nlen < $syslen} return
@@ -106,42 +106,42 @@
106106
# -----------------------------------------------------------------------------
107107
# Internal operations - Standard output operation
108108
109109
# Dispatch to the handlers of the possible operations.
110110
111
-proc ::tools::log::OUT {op args} {
112
- eval [linsert $args 0 ::tools::log::OUT/$op]
111
+proc ::vc::tools::log::OUT {op args} {
112
+ eval [linsert $args 0 ::vc::tools::log::OUT/$op]
113113
return
114114
}
115115
116116
# Write handler. Each message is a line.
117117
118
-proc ::tools::log::OUT/write {system text} {
118
+proc ::vc::tools::log::OUT/write {system text} {
119119
puts "$system $text"
120120
return
121121
}
122122
123
-# Progress handler. Using \r to return to the beginning of the current
123
+# Progress handler. Uses \r to return to the beginning of the current
124124
# line without advancing.
125125
126
-proc ::tools::log::OUT/progress {system n max} {
126
+proc ::vc::tools::log::OUT/progress {system n max} {
127127
puts -nonewline "$system [format %[string length $max]s $n]/$max\r"
128128
flush stdout
129129
return
130130
}
131131
132132
# -----------------------------------------------------------------------------
133133
134
-namespace eval ::tools::log {
135
- variable loglevel 0 ; # Allow only uninteruptible messages.
136
- variable logcmd ::tools::log::OUT ; # Standard output to stdout.
137
- variable sysfmt %s ; # Non-tabular formatting.
138
- variable syslen 0 ; # Ditto.
134
+namespace eval ::vc::tools::log {
135
+ variable loglevel 0 ; # Allow only uninteruptible messages.
136
+ variable logcmd ::vc::tools::log::OUT ; # Standard output to stdout.
137
+ variable sysfmt %s ; # Non-tabular formatting.
138
+ variable syslen 0 ; # Ditto.
139139
140140
namespace export write progress
141141
}
142142
143143
# -----------------------------------------------------------------------------
144144
# Ready
145145
146
-package provide tools::log 1.0
146
+package provide vc::tools::log 1.0
147147
return
148148
--- tools/lib/log.tcl
+++ tools/lib/log.tcl
@@ -3,26 +3,26 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 namespace eval ::tools::log {}
9
10 # -----------------------------------------------------------------------------
11 # API
12
13 # Feedback generation.
14 #
15 # tools::log::write verbosity system text - Write message to the log.
16 # tools::log::progress verbosity system n max - Drive a progress display.
17
18 # Administrative operations.
19 #
20 # tools::log::verbosity level - Set the verbosity level of the application.
21 # tools::log::verbosity? - Query the verbosity level of the application.
22 # tools::log::setCmd cmdprefix - Set callback for output
23 # tools::log::system name - Register a system (enables tabular log formatting).
24
25 # Callback API ( Executed at the global level).
26 #
27 # cmdprefix 'write' system text
28 # cmdprefix 'progress' system n max
@@ -34,11 +34,11 @@
34
35 # Write the message 'text' to log, for the named 'system'. The message
36 # is written if and only if the message verbosity is less or equal the
37 # chosen verbosity. A message of verbosity 0 cannot be blocked.
38
39 proc ::tools::log::write {verbosity system text} {
40 variable loglevel
41 variable logcmd
42 variable sysfmt
43 if {$verbosity > $loglevel} return
44 uplevel #0 [linsert $logcmd end write [format $sysfmt $system] $text]
@@ -47,11 +47,11 @@
47
48 # Similar to write, especially in the handling of the verbosity, to
49 # drive progress displays. It signals that for some long running
50 # operation we are at tick 'n' of at most 'max' ticks.
51
52 proc ::tools::log::progress {verbosity system n max} {
53 variable loglevel
54 variable logcmd
55 variable sysfmt
56 if {$verbosity > $loglevel} return
57 uplevel #0 [linsert $logcmd end progress [format $sysfmt $system] $n $max]
@@ -62,38 +62,38 @@
62 # API Implementation - Administrative operations.
63
64 # Set verbosity to the chosen 'level'. Only messages with a level less
65 # or equal to this one will be shown.
66
67 proc ::tools::log::verbosity {level} {
68 variable loglevel
69 if {$level < 1} {set level 0}
70 set loglevel $level
71 return
72 }
73
74 # Query the currently set verbosity.
75
76 proc ::tools::log::verbosity? {} {
77 variable loglevel
78 return $loglevel
79 }
80
81 # Set the log callback handling the actual output of messages going
82 # through the package.
83
84 proc ::tools::log::setCmd {cmdprefix} {
85 variable logcmd $cmdprefix
86 return
87 }
88
89 # Register a system name, to enable tabular formatting. This is done
90 # by setting up a format specifier with a proper width. This is
91 # handled in the generation command, before the output callback is
92 # invoked.
93
94 proc ::tools::log::system {name} {
95 variable sysfmt
96 variable syslen
97
98 set nlen [string length $name]
99 if {$nlen < $syslen} return
@@ -106,42 +106,42 @@
106 # -----------------------------------------------------------------------------
107 # Internal operations - Standard output operation
108
109 # Dispatch to the handlers of the possible operations.
110
111 proc ::tools::log::OUT {op args} {
112 eval [linsert $args 0 ::tools::log::OUT/$op]
113 return
114 }
115
116 # Write handler. Each message is a line.
117
118 proc ::tools::log::OUT/write {system text} {
119 puts "$system $text"
120 return
121 }
122
123 # Progress handler. Using \r to return to the beginning of the current
124 # line without advancing.
125
126 proc ::tools::log::OUT/progress {system n max} {
127 puts -nonewline "$system [format %[string length $max]s $n]/$max\r"
128 flush stdout
129 return
130 }
131
132 # -----------------------------------------------------------------------------
133
134 namespace eval ::tools::log {
135 variable loglevel 0 ; # Allow only uninteruptible messages.
136 variable logcmd ::tools::log::OUT ; # Standard output to stdout.
137 variable sysfmt %s ; # Non-tabular formatting.
138 variable syslen 0 ; # Ditto.
139
140 namespace export write progress
141 }
142
143 # -----------------------------------------------------------------------------
144 # Ready
145
146 package provide tools::log 1.0
147 return
148
--- tools/lib/log.tcl
+++ tools/lib/log.tcl
@@ -3,26 +3,26 @@
3
4 # -----------------------------------------------------------------------------
5 # Requirements
6
7 package require Tcl 8.4
8 namespace eval ::vc::tools::log {}
9
10 # -----------------------------------------------------------------------------
11 # API
12
13 # Feedback generation.
14 #
15 # vc::tools::log::write verbosity system text - Write message to the log.
16 # vc::tools::log::progress verbosity system n max - Drive a progress display.
17
18 # Administrative operations.
19 #
20 # vc::tools::log::verbosity level - Set the verbosity level of the application.
21 # vc::tools::log::verbosity? - Query the verbosity level of the application.
22 # vc::tools::log::setCmd cmdprefix - Set callback for output
23 # vc::tools::log::system name - Register a system (enables tabular log formatting).
24
25 # Callback API ( Executed at the global level).
26 #
27 # cmdprefix 'write' system text
28 # cmdprefix 'progress' system n max
@@ -34,11 +34,11 @@
34
35 # Write the message 'text' to log, for the named 'system'. The message
36 # is written if and only if the message verbosity is less or equal the
37 # chosen verbosity. A message of verbosity 0 cannot be blocked.
38
39 proc ::vc::tools::log::write {verbosity system text} {
40 variable loglevel
41 variable logcmd
42 variable sysfmt
43 if {$verbosity > $loglevel} return
44 uplevel #0 [linsert $logcmd end write [format $sysfmt $system] $text]
@@ -47,11 +47,11 @@
47
48 # Similar to write, especially in the handling of the verbosity, to
49 # drive progress displays. It signals that for some long running
50 # operation we are at tick 'n' of at most 'max' ticks.
51
52 proc ::vc::tools::log::progress {verbosity system n max} {
53 variable loglevel
54 variable logcmd
55 variable sysfmt
56 if {$verbosity > $loglevel} return
57 uplevel #0 [linsert $logcmd end progress [format $sysfmt $system] $n $max]
@@ -62,38 +62,38 @@
62 # API Implementation - Administrative operations.
63
64 # Set verbosity to the chosen 'level'. Only messages with a level less
65 # or equal to this one will be shown.
66
67 proc ::vc::tools::log::verbosity {level} {
68 variable loglevel
69 if {$level < 1} {set level 0}
70 set loglevel $level
71 return
72 }
73
74 # Query the currently set verbosity.
75
76 proc ::vc::tools::log::verbosity? {} {
77 variable loglevel
78 return $loglevel
79 }
80
81 # Set the log callback handling the actual output of messages going
82 # through the package.
83
84 proc ::vc::tools::log::setCmd {cmdprefix} {
85 variable logcmd $cmdprefix
86 return
87 }
88
89 # Register a system name, to enable tabular formatting. This is done
90 # by setting up a format specifier with a proper width. This is
91 # handled in the generation command, before the output callback is
92 # invoked.
93
94 proc ::vc::tools::log::system {name} {
95 variable sysfmt
96 variable syslen
97
98 set nlen [string length $name]
99 if {$nlen < $syslen} return
@@ -106,42 +106,42 @@
106 # -----------------------------------------------------------------------------
107 # Internal operations - Standard output operation
108
109 # Dispatch to the handlers of the possible operations.
110
111 proc ::vc::tools::log::OUT {op args} {
112 eval [linsert $args 0 ::vc::tools::log::OUT/$op]
113 return
114 }
115
116 # Write handler. Each message is a line.
117
118 proc ::vc::tools::log::OUT/write {system text} {
119 puts "$system $text"
120 return
121 }
122
123 # Progress handler. Uses \r to return to the beginning of the current
124 # line without advancing.
125
126 proc ::vc::tools::log::OUT/progress {system n max} {
127 puts -nonewline "$system [format %[string length $max]s $n]/$max\r"
128 flush stdout
129 return
130 }
131
132 # -----------------------------------------------------------------------------
133
134 namespace eval ::vc::tools::log {
135 variable loglevel 0 ; # Allow only uninteruptible messages.
136 variable logcmd ::vc::tools::log::OUT ; # Standard output to stdout.
137 variable sysfmt %s ; # Non-tabular formatting.
138 variable syslen 0 ; # Ditto.
139
140 namespace export write progress
141 }
142
143 # -----------------------------------------------------------------------------
144 # Ready
145
146 package provide vc::tools::log 1.0
147 return
148
--- tools/lib/pkgIndex.tcl
+++ tools/lib/pkgIndex.tcl
@@ -1,6 +1,6 @@
11
if {![package vsatisfies [package require Tcl] 8.4]} return
22
package ifneeded rcsparser 1.0 [list source [file join $dir rcsparser.tcl]]
33
package ifneeded cvs 1.0 [list source [file join $dir cvs.tcl]]
44
package ifneeded fossil 1.0 [list source [file join $dir fossil.tcl]]
5
-package ifneeded tools::log 1.0 [list source [file join $dir log.tcl]]
65
package ifneeded import::cvs 1.0 [list source [file join $dir importcvs.tcl]]
6
+package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
77
--- tools/lib/pkgIndex.tcl
+++ tools/lib/pkgIndex.tcl
@@ -1,6 +1,6 @@
1 if {![package vsatisfies [package require Tcl] 8.4]} return
2 package ifneeded rcsparser 1.0 [list source [file join $dir rcsparser.tcl]]
3 package ifneeded cvs 1.0 [list source [file join $dir cvs.tcl]]
4 package ifneeded fossil 1.0 [list source [file join $dir fossil.tcl]]
5 package ifneeded tools::log 1.0 [list source [file join $dir log.tcl]]
6 package ifneeded import::cvs 1.0 [list source [file join $dir importcvs.tcl]]
 
7
--- tools/lib/pkgIndex.tcl
+++ tools/lib/pkgIndex.tcl
@@ -1,6 +1,6 @@
1 if {![package vsatisfies [package require Tcl] 8.4]} return
2 package ifneeded rcsparser 1.0 [list source [file join $dir rcsparser.tcl]]
3 package ifneeded cvs 1.0 [list source [file join $dir cvs.tcl]]
4 package ifneeded fossil 1.0 [list source [file join $dir fossil.tcl]]
 
5 package ifneeded import::cvs 1.0 [list source [file join $dir importcvs.tcl]]
6 package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
7
--- tools/lib/rcsparser.tcl
+++ tools/lib/rcsparser.tcl
@@ -10,16 +10,16 @@
1010
1111
# -----------------------------------------------------------------------------
1212
# Requirements
1313
1414
package require Tcl 8.4
15
-package require fileutil ; # Tcllib (cat)
16
-package require tools::log ; # User feedback
15
+package require fileutil ; # Tcllib (cat)
16
+package require vc::tools::log ; # User feedback
1717
1818
namespace eval ::rcsparser {
19
- tools::log::system rcs
20
- namespace import ::tools::log::progress
19
+ vc::tools::log::system rcs
20
+ namespace import ::vc::tools::log::progress
2121
}
2222
2323
# -----------------------------------------------------------------------------
2424
# API
2525
2626
--- tools/lib/rcsparser.tcl
+++ tools/lib/rcsparser.tcl
@@ -10,16 +10,16 @@
10
11 # -----------------------------------------------------------------------------
12 # Requirements
13
14 package require Tcl 8.4
15 package require fileutil ; # Tcllib (cat)
16 package require tools::log ; # User feedback
17
18 namespace eval ::rcsparser {
19 tools::log::system rcs
20 namespace import ::tools::log::progress
21 }
22
23 # -----------------------------------------------------------------------------
24 # API
25
26
--- tools/lib/rcsparser.tcl
+++ tools/lib/rcsparser.tcl
@@ -10,16 +10,16 @@
10
11 # -----------------------------------------------------------------------------
12 # Requirements
13
14 package require Tcl 8.4
15 package require fileutil ; # Tcllib (cat)
16 package require vc::tools::log ; # User feedback
17
18 namespace eval ::rcsparser {
19 vc::tools::log::system rcs
20 namespace import ::vc::tools::log::progress
21 }
22
23 # -----------------------------------------------------------------------------
24 # API
25
26

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button