1
0
Fork 0

Move the policy about the areas into the LogManager

This commit is contained in:
Holger Hans Peter Freyther 2010-09-08 23:20:58 +08:00
parent d16a9da541
commit 5dc9296b36
1 changed files with 40 additions and 43 deletions

View File

@ -154,10 +154,48 @@ Object subclass: LogArea [
]
Object subclass: LogTarget [
| areas |
<category: 'osmo-logging-core'>
<comment: 'I will filter and then output the log message'>
print: anEntry [
<category: 'log'>
self subclassResponsibility.
]
]
LogTarget subclass: LogTranscriptTarget [
<category: 'osmo-logging-target'>
<comment: 'I log to the Transcript buffer'>
print: anEntry [
<category: 'log'>
Transcript show: anEntry msg; nl.
]
]
Object subclass: LogManager [
| target areas |
<category: 'osmo-logging-core'>
<comment: 'I handle the actual log invocation'>
Log := nil.
LogManager class >> default [
<category: 'instance'>
Log ifNil: [
Log := LogManager new.
Log target: LogTranscriptTarget new.
].
^ Log
]
target: aTarget [
<category: 'private'>
target := aTarget.
]
areas [
<category: 'accessing'>
areas ifNil: [
@ -193,48 +231,7 @@ Object subclass: LogTarget [
log: anEntry [
<category: 'log'>
self handle: anEntry ifTrue: [
self print: anEntry.
target print: anEntry
]
]
print: anEntry [
<category: 'log'>
self subclassResponsibility.
]
]
LogTarget subclass: LogTranscriptTarget [
<category: 'osmo-logging-target'>
<comment: 'I log to the Transcript buffer'>
print: anEntry [
<category: 'log'>
Transcript show: anEntry msg; nl.
]
]
Object subclass: LogManager [
| target |
<category: 'osmo-logging-core'>
<comment: 'I handle the actual log invocation'>
Log := nil.
LogManager class >> default [
<category: 'instance'>
Log ifNil: [
Log := LogManager new.
Log target: LogTranscriptTarget new.
].
^ Log
]
log: anEntry [
target log: anEntry.
]
target: aTarget [
target := aTarget.
]
]