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 [
|
logConfig [
|
||||||
<category: '*osmo-logging-core'>
|
<category: '*osmo-logging-core'>
|
||||||
"I provide access to the global LogConfig"
|
"I provide access to the global LogConfig"
|
||||||
^ LogConfig instance
|
^ LogConfig default
|
||||||
]
|
]
|
||||||
|
|
||||||
logManager [
|
logManager [
|
||||||
|
@ -63,7 +63,7 @@ Object subclass: LogArea [
|
||||||
<category: 'osmo-logging-core'>
|
<category: 'osmo-logging-core'>
|
||||||
<comment: 'I represent one LogArea and have status'>
|
<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'>
|
<category: 'instance'>
|
||||||
^ (LogArea new)
|
^ (LogArea new)
|
||||||
name: aName;
|
name: aName;
|
||||||
|
@ -92,20 +92,18 @@ Object subclass: LogArea [
|
||||||
enabled := anEnabled.
|
enabled := anEnabled.
|
||||||
]
|
]
|
||||||
|
|
||||||
level [
|
minLevel [
|
||||||
<category: 'accessing'>
|
<category: 'accessing'>
|
||||||
^ level
|
^ level
|
||||||
]
|
]
|
||||||
|
|
||||||
level: aLevel [
|
minLevel: aLevel [
|
||||||
<category: 'accessing'>
|
<category: 'accessing'>
|
||||||
level := aLevel
|
level := aLevel
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
Object subclass: LogConfig [
|
Object subclass: LogConfig [
|
||||||
| areas |
|
|
||||||
|
|
||||||
<category: 'osmo-logging-core'>
|
<category: 'osmo-logging-core'>
|
||||||
<comment: 'I handle the config, the backends, the log areas, the default level'>
|
<comment: 'I handle the config, the backends, the log areas, the default level'>
|
||||||
|
|
||||||
|
@ -121,14 +119,14 @@ Object subclass: LogConfig [
|
||||||
<category: 'management'>
|
<category: 'management'>
|
||||||
"Add the area to the list of areas"
|
"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 instVarNamed: aName asSymbol put: anArea.
|
||||||
self class compile: aName, '[ ^ ', aName, ']' classified: 'area-access'.
|
self class compile: aName, '[ ^ ', aName, ']' classified: 'area-access'.
|
||||||
]
|
]
|
||||||
|
|
||||||
areas [
|
|
||||||
^ areas
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
Object subclass: LogManager [
|
Object subclass: LogManager [
|
||||||
|
@ -144,6 +142,24 @@ Object subclass: LogManager [
|
||||||
|
|
||||||
log: message source: anObject area: anArea level: anLevel [
|
log: message source: anObject area: anArea level: anLevel [
|
||||||
<category: 'log'>
|
<category: 'log'>
|
||||||
|
| config area |
|
||||||
|
|
||||||
|
config := anObject logConfig.
|
||||||
|
area := config perform: anArea asSymbol.
|
||||||
|
|
||||||
|
area enabled
|
||||||
|
ifTrue: [
|
||||||
Transcript show: message; nl.
|
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