author | Claus Gittinger <cg@exept.de> |
Fri, 18 Jul 2014 17:17:03 +0200 | |
changeset 16783 | 63f50747750a |
parent 16782 | ee6003ea5c4e |
child 16784 | 05fdf667949e |
permissions | -rw-r--r-- |
13810 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic' }" |
|
13 |
||
14 |
Object subclass:#MiniLogger |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'Instance' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'System-Debugging-Support' |
|
19 |
! |
|
20 |
||
21 |
!MiniLogger class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! ! |
|
36 |
||
37 |
!MiniLogger class methodsFor:'instance creation'! |
|
38 |
||
39 |
instance |
|
40 |
Instance isNil ifTrue:[Instance := self basicNew]. |
|
41 |
^Instance |
|
42 |
||
43 |
"Created: / 14-09-2011 / 21:28:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
44 |
! |
|
45 |
||
46 |
new |
|
47 |
Logger log: 'Do not use MiniLogger new, use #instance instead' severity: #warn facility: 'STX'. |
|
48 |
^self instance |
|
49 |
||
50 |
"Created: / 14-09-2011 / 21:27:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
51 |
! ! |
|
52 |
||
53 |
!MiniLogger class methodsFor:'class initialization'! |
|
54 |
||
55 |
initialize |
|
56 |
(Smalltalk at:#Logger) isNil ifTrue:[Smalltalk at:#Logger put: self instance]. |
|
57 |
||
58 |
"Created: / 01-09-2011 / 12:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
59 |
! ! |
|
60 |
||
61 |
!MiniLogger methodsFor:'logging'! |
|
62 |
||
16782 | 63 |
facilityOf:originator |
64 |
^ originator class |
|
65 |
perform:#logFacility |
|
66 |
ifNotUnderstood:[ |
|
67 |
|pkg| |
|
13810 | 68 |
|
69 |
pkg := originator class package. |
|
16782 | 70 |
(pkg startsWith:'stx') ifTrue:[ |
13810 | 71 |
'STX' |
72 |
] ifFalse:[ |
|
16782 | 73 |
pkg copyFrom:((pkg lastIndexOf:$:) + 1) |
13810 | 74 |
] |
75 |
] |
|
76 |
||
77 |
" |
|
16782 | 78 |
Logger facilityOf: Object |
79 |
Logger facilityOf: Expecco::Browser |
|
13810 | 80 |
" |
81 |
||
82 |
"Created: / 15-09-2011 / 10:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
83 |
! |
|
84 |
||
85 |
log: message |
|
86 |
self log: message severity: #debug |
|
87 |
||
88 |
"Created: / 15-09-2011 / 10:27:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
89 |
! |
|
90 |
||
91 |
log: message facility: facility |
|
92 |
self log: message severity: #debug facility: facility |
|
93 |
||
94 |
"Created: / 14-09-2011 / 21:22:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
95 |
! |
|
96 |
||
97 |
log: message severity: severity |
|
98 |
self log: message severity: #debug originator: thisContext sender receiver |
|
99 |
||
100 |
"Created: / 15-09-2011 / 10:25:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
101 |
! |
|
102 |
||
103 |
log: message severity: severity attachment: attachment |
|
16782 | 104 |
| originator | |
13810 | 105 |
|
106 |
originator := thisContext sender receiver. |
|
107 |
||
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
108 |
self log: message severity: severity facility: (self facilityOf: originator) originator: originator attachment: attachment |
13810 | 109 |
|
110 |
"Created: / 15-09-2011 / 11:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
111 |
"Modified: / 15-03-2013 / 11:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13810 | 112 |
! |
113 |
||
114 |
log: message severity: severity facility: facility |
|
115 |
self log: message severity: severity facility: facility originator: thisContext sender receiver |
|
116 |
||
117 |
"Created: / 14-09-2011 / 21:20:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118 |
! |
|
119 |
||
120 |
log: message severity: severity facility: facility originator: originator |
|
121 |
self log: message severity: severity facility: facility originator: originator attachment: nil |
|
122 |
||
123 |
"Created: / 14-09-2011 / 21:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
124 |
! |
|
125 |
||
126 |
log: message severity: severity facility: facility originator: originator attachment: attachment |
|
127 |
"Pricipal logging method. This mimics VM __stxLog__()" |
|
128 |
||
16783 | 129 |
self log: message severity: severity facility: facility originator: originator attachment: attachment on:Stderr. |
130 |
Transcript ~~ Stderr ifTrue:[ |
|
131 |
self log: message severity: severity facility: facility originator: originator attachment: attachment on:Transcript |
|
132 |
]. |
|
133 |
||
134 |
" |
|
135 |
Logger log:'test message' severity: #debug facility: 'TEST' |
|
136 |
" |
|
137 |
||
138 |
"Created: / 14-09-2011 / 21:18:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139 |
! |
|
140 |
||
141 |
log: message severity: severity facility: facility originator: originator attachment: attachment on:aStream |
|
142 |
"Pricipal logging method. This mimics VM __stxLog__()" |
|
143 |
||
144 |
aStream |
|
13810 | 145 |
nextPutAll: facility ? 'STX'; |
146 |
space; |
|
147 |
nextPut:$[; |
|
148 |
nextPutAll: severity; |
|
149 |
nextPut:$]; |
|
150 |
space. |
|
151 |
||
16783 | 152 |
aStream nextPut:$(. |
153 |
Timestamp now printOn:aStream format:'%(year)-%(mon)-%(day) %h:%m:%s'. |
|
154 |
aStream nextPut:$). |
|
155 |
aStream space. |
|
156 |
aStream nextPutAll: message. |
|
157 |
aStream cr. |
|
13810 | 158 |
|
159 |
" |
|
16783 | 160 |
Logger log:'test message' severity: #debug facility: 'TEST' |
13810 | 161 |
" |
162 |
||
163 |
"Created: / 14-09-2011 / 21:18:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
164 |
! |
|
165 |
||
166 |
log: message severity: severity originator: originator |
|
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
167 |
self log: message severity: severity facility: (self facilityOf: originator) originator: originator |
13810 | 168 |
|
169 |
"Created: / 15-09-2011 / 10:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
170 |
"Modified: / 15-03-2013 / 11:20:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13810 | 171 |
! ! |
172 |
||
173 |
!MiniLogger class methodsFor:'documentation'! |
|
174 |
||
175 |
version |
|
16783 | 176 |
^ '$Header: /cvs/stx/stx/libbasic/MiniLogger.st,v 1.4 2014-07-18 15:17:03 cg Exp $' |
13810 | 177 |
! |
178 |
||
179 |
version_CVS |
|
16783 | 180 |
^ '$Header: /cvs/stx/stx/libbasic/MiniLogger.st,v 1.4 2014-07-18 15:17:03 cg Exp $' |
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
181 |
! |
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
182 |
|
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
183 |
version_HG |
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
184 |
|
16782 | 185 |
^ '$Changeset: <not expanded> $' |
13810 | 186 |
! |
187 |
||
188 |
version_SVN |
|
16783 | 189 |
^ '$Id: MiniLogger.st,v 1.4 2014-07-18 15:17:03 cg Exp $' |
13810 | 190 |
! ! |
191 |
||
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
192 |
|
13810 | 193 |
MiniLogger initialize! |