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 |
|
|
114 |
self log: message severity: #debug facility: (self facilityOf: originator) originator: originator attachment: attachment
|
|
115 |
|
|
116 |
"Created: / 15-09-2011 / 11:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
117 |
!
|
|
118 |
|
|
119 |
log: message severity: severity facility: facility
|
|
120 |
|
|
121 |
self log: message severity: severity facility: facility originator: thisContext sender receiver
|
|
122 |
|
|
123 |
"Created: / 14-09-2011 / 21:20:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
124 |
!
|
|
125 |
|
|
126 |
log: message severity: severity facility: facility originator: originator
|
|
127 |
|
|
128 |
self log: message severity: severity facility: facility originator: originator attachment: nil
|
|
129 |
|
|
130 |
"Created: / 14-09-2011 / 21:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
131 |
!
|
|
132 |
|
|
133 |
log: message severity: severity facility: facility originator: originator attachment: attachment
|
|
134 |
|
|
135 |
"Pricipal logging method. This mimics VM __stxLog__()"
|
|
136 |
|
|
137 |
Stderr
|
|
138 |
nextPutAll: facility ? 'STX';
|
|
139 |
space;
|
|
140 |
nextPut:$[;
|
|
141 |
nextPutAll: severity;
|
|
142 |
nextPut:$];
|
|
143 |
space.
|
|
144 |
|
|
145 |
Stderr nextPut:$(.
|
|
146 |
Timestamp now printOn:Stderr format:'%(year)-%(mon)-%(day) %h:%m:%s'.
|
|
147 |
Stderr nextPut:$).
|
|
148 |
Stderr space.
|
|
149 |
Stderr nextPutAll: message.
|
|
150 |
Stderr cr.
|
|
151 |
|
|
152 |
"
|
|
153 |
Logger log:'test message' severity: #debug facility: 'TEST'
|
|
154 |
"
|
|
155 |
|
|
156 |
"Created: / 14-09-2011 / 21:18:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
157 |
!
|
|
158 |
|
|
159 |
log: message severity: severity originator: originator
|
|
160 |
|
|
161 |
self log: message severity: #debug facility: (self facilityOf: originator) originator: originator
|
|
162 |
|
|
163 |
"Created: / 15-09-2011 / 10:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
164 |
! !
|
|
165 |
|
|
166 |
!MiniLogger class methodsFor:'documentation'!
|
|
167 |
|
|
168 |
version
|
|
169 |
^ '$Header: /cvs/stx/stx/libbasic/MiniLogger.st,v 1.1 2011-10-31 16:06:38 vrany Exp $'
|
|
170 |
!
|
|
171 |
|
|
172 |
version_CVS
|
|
173 |
^ '$Header: /cvs/stx/stx/libbasic/MiniLogger.st,v 1.1 2011-10-31 16:06:38 vrany Exp $'
|
|
174 |
!
|
|
175 |
|
|
176 |
version_SVN
|
|
177 |
^ '§Id: MiniLogger.st 10688 2011-09-15 11:05:35Z vranyj1 §'
|
|
178 |
! !
|
|
179 |
|
|
180 |
MiniLogger initialize!
|