smalltalk
/
osmo-st-all
Archived
1
0
Fork 0

Merge branch 'master' of git://git.osmocom.org/smalltalk/osmo-st-logging

This commit is contained in:
Holger Hans Peter Freyther 2013-05-23 17:37:01 +02:00
commit 175366c124
5 changed files with 69 additions and 15 deletions

2
osmo-st-logging/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.sw?
fileout.st

View File

@ -18,42 +18,42 @@
Object extend [
logManager [
<category: '*osmo-logging-core'>
<category: '*OsmoLogging-Core'>
^ Osmo.LogManager default
]
logDataContext: aData area: anArea [
<category: '*osmo-logging-core'>
<category: '*OsmoLogging-Core'>
(self logManager)
context: 'data' value: aData.
]
logDebug: aMessage area: anArea [
<category: '*osmo-logging-core'>
<category: '*OsmoLogging-Core'>
(self logManager)
log: (LogEntry withMsg: aMessage level: LogLevel debug area: anArea context: self)
]
logInfo: aMessage area: anArea [
<category: '*osmo-logging-core'>
<category: '*OsmoLogging-Core'>
(self logManager)
log: (LogEntry withMsg: aMessage level: LogLevel info area: anArea context: self)
]
logNotice: aMessage area: anArea [
<category: '*osmo-logging-core'>
<category: '*OsmoLogging-Core'>
(self logManager)
log: (LogEntry withMsg: aMessage level: LogLevel notice area: anArea context: self)
]
logError: aMessage area: anArea [
<category: '*osmo-logging-core'>
<category: '*OsmoLogging-Core'>
(self logManager)
log: (LogEntry withMsg: aMessage level: LogLevel error area: anArea context: self)
]
logException: aMessage area: anArea [
<category: '*osmo-logging-exception'>
<category: '*OsmoLogging-Core'>
(self logManager)
exception: (LogEntry withMsg: aMessage
level: LogLevel error
@ -64,7 +64,7 @@ Object extend [
Object subclass: LogEntry [
| level ctx area msg |
<category: 'osmo-logging-core'>
<category: 'OsmoLogging-Core'>
<comment: 'I represent a log entry and hold the text, level, area'>
LogEntry class >> withMsg: aMsg level: anLevel area: anArea context: aContext [
@ -110,7 +110,7 @@ Object subclass: LogEntry [
]
Object subclass: LogLevel [
<category: 'osmo-logging-core'>
<category: 'OsmoLogging-Core'>
<comment: 'I represent the available levels for log messages'>
LogLevel class >> debug [
@ -132,7 +132,7 @@ Object subclass: LogLevel [
Object subclass: LogArea [
| name enabled level |
<category: 'osmo-logging-core'>
<category: 'OsmoLogging-Core'>
<comment: 'I represent a LogArea'>
LogArea class >> defaultForArea: aSymbol [
@ -191,7 +191,7 @@ Object subclass: LogArea [
]
Object subclass: LogTarget [
<category: 'osmo-logging-core'>
<category: 'OsmoLogging-Target'>
<comment: 'I will filter and then output the log message'>
@ -207,7 +207,7 @@ Object subclass: LogTarget [
]
LogTarget subclass: LogTranscriptTarget [
<category: 'osmo-logging-target'>
<category: 'OsmoLogging-Target'>
<comment: 'I log to the Transcript buffer'>
print: anEntry [
@ -223,7 +223,7 @@ LogTarget subclass: LogTranscriptTarget [
]
Object subclass: LogFilter [
<category: 'osmo-logging-core'>
<category: 'OsmoLogging-Core'>
<comment: 'I filter based on mood, context and Bangkok Law'>
filter: anEntry [
@ -236,7 +236,7 @@ Object subclass: LogFilter [
Object subclass: LogManager [
| target filter areas |
<category: 'osmo-logging-core'>
<category: 'OsmoLogging-Core'>
<comment: 'I handle the actual log invocation'>
Log := nil.

View File

@ -19,7 +19,7 @@
LogTarget subclass: LogTargetSyslog [
| prefix |
<comment: 'I can log everything to the syslog.'>
<category: 'osmo-logging-syslog'>
<category: 'OsmoLogging-Syslog'>
LogMap := nil.

17
osmo-st-logging/Makefile Normal file
View File

@ -0,0 +1,17 @@
GST_PACKAGE = gst-package
GST_CONVERT = gst-convert
CONVERT_RULES = -r'Osmo.LogManager->LogManager' \
-r'(Transcript nl)->(Transcript cr)' \
-r'(thisContext parentContext)->(thisContext sender)' \
-r'(``@object backtraceOn: ``@args1)->(``@object printOn: ``@args1)' \
-r'ProcessVariable->GSTProcessVariable'
all:
$(GST_PACKAGE) --test package.xml
convert:
$(GST_CONVERT) $(CONVERT_RULES) -F squeak -f gst \
-o fileout.st compat_for_pharo.st LogManager.st

View File

@ -0,0 +1,35 @@
Object subclass: GSTProcessVariableHolder [
| val |
<category: 'OsmoLogging-Pharo'>
value: aValue [
<category: 'set'>
val := val.
]
value [
<category: 'get'>
^ val
]
]
ProcessLocalVariable subclass: GSTProcessVariable [
| dict |
<category: 'OsmoLogging-Pharo'>
GSTProcessVariable class >> key: aKey [
<category: 'creation'>
^ self soleInstance key: aKey.
]
dict [
<category: 'creation'>
^ dict ifNil: [dict := Dictionary new].
]
key: aKey [
<category: 'key'>
^ self dict at: aKey ifAbsent:
[self dict at: aKey put: GSTProcessVariableHolder new].
]
]