Fix the logging, log at the enabled status
- Use the right selector - Get the area, look at the enabled status
This commit is contained in:
parent
f14a0b250b
commit
863f48be8c
|
@ -4,7 +4,7 @@ Object extend [
|
|||
logConfig [
|
||||
<category: '*osmo-logging-core'>
|
||||
"I provide access to the global LogConfig"
|
||||
^ LogConfig instance
|
||||
^ LogConfig default
|
||||
]
|
||||
|
||||
logManager [
|
||||
|
@ -63,7 +63,7 @@ Object subclass: LogArea [
|
|||
<category: 'osmo-logging-core'>
|
||||
<comment: 'I represent one LogArea and have status'>
|
||||
|
||||
LogArea class >> withName: aName enabled: anEnabled level: aLevel [
|
||||
LogArea class >> withName: aName enabled: anEnabled minLevel: aLevel [
|
||||
<category: 'instance'>
|
||||
^ (LogArea new)
|
||||
name: aName;
|
||||
|
@ -92,20 +92,18 @@ Object subclass: LogArea [
|
|||
enabled := anEnabled.
|
||||
]
|
||||
|
||||
level [
|
||||
minLevel [
|
||||
<category: 'accessing'>
|
||||
^ level
|
||||
]
|
||||
|
||||
level: aLevel [
|
||||
minLevel: aLevel [
|
||||
<category: 'accessing'>
|
||||
level := aLevel
|
||||
]
|
||||
]
|
||||
|
||||
Object subclass: LogConfig [
|
||||
| areas |
|
||||
|
||||
<category: 'osmo-logging-core'>
|
||||
<comment: 'I handle the config, the backends, the log areas, the default level'>
|
||||
|
||||
|
@ -121,14 +119,14 @@ Object subclass: LogConfig [
|
|||
<category: 'management'>
|
||||
"Add the area to the list of areas"
|
||||
|
||||
self class addInstVarName: aName asSymbol.
|
||||
(self class instVarNames includes: aName asSymbol)
|
||||
ifFalse: [
|
||||
self class addInstVarName: aName asSymbol
|
||||
].
|
||||
|
||||
self instVarNamed: aName asSymbol put: anArea.
|
||||
self class compile: aName, '[ ^ ', aName, ']' classified: 'area-access'.
|
||||
]
|
||||
|
||||
areas [
|
||||
^ areas
|
||||
]
|
||||
]
|
||||
|
||||
Object subclass: LogManager [
|
||||
|
@ -144,6 +142,24 @@ Object subclass: LogManager [
|
|||
|
||||
log: message source: anObject area: anArea level: anLevel [
|
||||
<category: 'log'>
|
||||
Transcript show: message; nl.
|
||||
| config area |
|
||||
|
||||
config := anObject logConfig.
|
||||
area := config perform: anArea asSymbol.
|
||||
|
||||
area enabled
|
||||
ifTrue: [
|
||||
Transcript show: message; nl.
|
||||
].
|
||||
]
|
||||
]
|
||||
|
||||
Eval [
|
||||
area := LogArea withName: 'Base is for Base' enabled: true minLevel: LogLevel debug.
|
||||
nothere := LogArea withName: 'Base is for Base' enabled: false minLevel: LogLevel debug.
|
||||
LogConfig default addArea: area name: #base.
|
||||
LogConfig default addArea: nothere name: #nothere.
|
||||
|
||||
'123' logDebug: 'Log Message' area: #base.
|
||||
'456' logDebug: 'Log Foo' area: #nothere
|
||||
]
|
||||
|
|
Reference in New Issue