aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-04-03 22:06:46 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-04-03 22:06:46 +0200
commitbdaff7cef1c025bd29e8cd71b24f9b6f9bd6994f (patch)
tree425cf62b4b7b21f42a68532061b75e086930065c
parent0aba20a89122fa13b460331fec410330699a1fd7 (diff)
log: Make it possible to log exceptions
-rw-r--r--LogManager.st26
-rw-r--r--LogTest.st6
2 files changed, 31 insertions, 1 deletions
diff --git a/LogManager.st b/LogManager.st
index 404e50d..756d806 100644
--- a/LogManager.st
+++ b/LogManager.st
@@ -51,6 +51,14 @@ Object extend [
(self logManager)
log: (LogEntry withMsg: aMessage level: LogLevel error area: anArea context: self)
]
+
+ logException: aMessage area: anArea [
+ <category: '*osmo-logging-exception'>
+ (self logManager)
+ exception: (LogEntry withMsg: aMessage
+ level: LogLevel error
+ area: anArea context: thisContext parentContext)
+ ]
]
Object subclass: LogEntry [
@@ -191,6 +199,11 @@ Object subclass: LogTarget [
<category: 'log'>
self subclassResponsibility.
]
+
+ exception: anEntry [
+ <category: 'log'>
+ self subclassResponsibility.
+ ]
]
LogTarget subclass: LogTranscriptTarget [
@@ -201,6 +214,12 @@ LogTarget subclass: LogTranscriptTarget [
<category: 'log'>
Transcript show: anEntry msg; nl.
]
+
+ exception: anEntry [
+ <category: 'log'>
+ Transcript show: anEntry msg; nl.
+ anEntry context backtraceOn: Transcript.
+ ]
]
Object subclass: LogFilter [
@@ -276,6 +295,13 @@ Object subclass: LogManager [
]
]
+ exception: anEntry [
+ <category: 'log'>
+ self handle: anEntry ifTrue: [
+ target exception: anEntry.
+ ]
+ ]
+
context: aString value: aValue [
| key |
key := Array with: 'LogArea' with: aString.
diff --git a/LogTest.st b/LogTest.st
index 91fdb61..00daa7e 100644
--- a/LogTest.st
+++ b/LogTest.st
@@ -16,7 +16,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
-LogArea subclass: LogAreaSCCP [
+PackageLoader fileInPackage: #OsmoLogging.
+
+Osmo.LogArea subclass: LogAreaSCCP [
LogAreaSCCP class >> areaName [
^ #sccp
]
@@ -35,4 +37,6 @@ LogArea subclass: LogAreaSCCP [
Eval [
'123' logDebug: 'TEST' area: #sccp.
+
+ '123' logException: 'TEST' area: #sccp.
]