author | Stefan Vogel <sv@exept.de> |
Fri, 31 May 2013 14:50:39 +0200 | |
changeset 15342 | d89884677c76 |
parent 14881 | 28ba52b80aa7 |
child 16782 | ee6003ea5c4e |
child 18033 | c90d8fdd805d |
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 |
||
41 |
Instance isNil ifTrue:[Instance := self basicNew]. |
|
42 |
^Instance |
|
43 |
||
44 |
"Created: / 14-09-2011 / 21:28:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
45 |
! |
|
46 |
||
47 |
new |
|
48 |
||
49 |
Logger log: 'Do not use MiniLogger new, use #instance instead' severity: #warn facility: 'STX'. |
|
50 |
^self instance |
|
51 |
||
52 |
"Created: / 14-09-2011 / 21:27:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
53 |
! ! |
|
54 |
||
55 |
!MiniLogger class methodsFor:'class initialization'! |
|
56 |
||
57 |
initialize |
|
58 |
||
59 |
(Smalltalk at:#Logger) isNil ifTrue:[Smalltalk at:#Logger put: self instance]. |
|
60 |
||
61 |
"Created: / 01-09-2011 / 12:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
62 |
! ! |
|
63 |
||
64 |
!MiniLogger methodsFor:'logging'! |
|
65 |
||
66 |
facilityOf: originator |
|
67 |
||
68 |
^originator class |
|
69 |
perform: #logFacility |
|
70 |
ifNotUnderstood: [ |
|
71 |
| pkg | |
|
72 |
pkg := originator class package. |
|
73 |
(pkg startsWith: 'stx') ifTrue:[ |
|
74 |
'STX' |
|
75 |
] ifFalse:[ |
|
76 |
pkg copyFrom: ((pkg lastIndexOf: $:) + 1) |
|
77 |
] |
|
78 |
] |
|
79 |
||
80 |
" |
|
81 |
Logger facilityOf: Object |
|
82 |
Logger facilityOf: Expecco::Browser |
|
83 |
" |
|
84 |
||
85 |
"Created: / 15-09-2011 / 10:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
86 |
! |
|
87 |
||
88 |
log: message |
|
89 |
||
90 |
self log: message severity: #debug |
|
91 |
||
92 |
"Created: / 15-09-2011 / 10:27:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
93 |
! |
|
94 |
||
95 |
log: message facility: facility |
|
96 |
||
97 |
self log: message severity: #debug facility: facility |
|
98 |
||
99 |
"Created: / 14-09-2011 / 21:22:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
100 |
! |
|
101 |
||
102 |
log: message severity: severity |
|
103 |
||
104 |
self log: message severity: #debug originator: thisContext sender receiver |
|
105 |
||
106 |
"Created: / 15-09-2011 / 10:25:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
107 |
! |
|
108 |
||
109 |
log: message severity: severity attachment: attachment |
|
110 |
||
111 |
| originator | |
|
112 |
originator := thisContext sender receiver. |
|
113 |
||
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
114 |
self log: message severity: severity facility: (self facilityOf: originator) originator: originator attachment: attachment |
13810 | 115 |
|
116 |
"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
|
117 |
"Modified: / 15-03-2013 / 11:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13810 | 118 |
! |
119 |
||
120 |
log: message severity: severity facility: facility |
|
121 |
||
122 |
self log: message severity: severity facility: facility originator: thisContext sender receiver |
|
123 |
||
124 |
"Created: / 14-09-2011 / 21:20:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
125 |
! |
|
126 |
||
127 |
log: message severity: severity facility: facility originator: originator |
|
128 |
||
129 |
self log: message severity: severity facility: facility originator: originator attachment: nil |
|
130 |
||
131 |
"Created: / 14-09-2011 / 21:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
132 |
! |
|
133 |
||
134 |
log: message severity: severity facility: facility originator: originator attachment: attachment |
|
135 |
||
136 |
"Pricipal logging method. This mimics VM __stxLog__()" |
|
137 |
||
138 |
Stderr |
|
139 |
nextPutAll: facility ? 'STX'; |
|
140 |
space; |
|
141 |
nextPut:$[; |
|
142 |
nextPutAll: severity; |
|
143 |
nextPut:$]; |
|
144 |
space. |
|
145 |
||
146 |
Stderr nextPut:$(. |
|
147 |
Timestamp now printOn:Stderr format:'%(year)-%(mon)-%(day) %h:%m:%s'. |
|
148 |
Stderr nextPut:$). |
|
149 |
Stderr space. |
|
150 |
Stderr nextPutAll: message. |
|
151 |
Stderr cr. |
|
152 |
||
153 |
" |
|
154 |
Logger log:'test message' severity: #debug facility: 'TEST' |
|
155 |
" |
|
156 |
||
157 |
"Created: / 14-09-2011 / 21:18:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
158 |
! |
|
159 |
||
160 |
log: message severity: severity originator: originator |
|
161 |
||
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
162 |
self log: message severity: severity facility: (self facilityOf: originator) originator: originator |
13810 | 163 |
|
164 |
"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
|
165 |
"Modified: / 15-03-2013 / 11:20:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13810 | 166 |
! ! |
167 |
||
168 |
!MiniLogger class methodsFor:'documentation'! |
|
169 |
||
170 |
version |
|
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
171 |
^ '$Header: /cvs/stx/stx/libbasic/MiniLogger.st,v 1.2 2013-03-15 11:21:39 vrany Exp $' |
13810 | 172 |
! |
173 |
||
174 |
version_CVS |
|
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
175 |
^ '$Header: /cvs/stx/stx/libbasic/MiniLogger.st,v 1.2 2013-03-15 11:21:39 vrany Exp $' |
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
176 |
! |
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
177 |
|
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
178 |
version_HG |
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
179 |
|
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
180 |
^ '§Changeset: <not expanded> §' |
13810 | 181 |
! |
182 |
||
183 |
version_SVN |
|
184 |
^ '§Id: MiniLogger.st 10688 2011-09-15 11:05:35Z vranyj1 §' |
|
185 |
! ! |
|
186 |
||
14881
28ba52b80aa7
Bugfixes: log using specified severity.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13810
diff
changeset
|
187 |
|
13810 | 188 |
MiniLogger initialize! |