#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Wed, 01 Mar 2017 10:39:27 +0100
changeset 21606 d8639d4653d5
parent 21605 806379005cac
child 21607 6eefa4f76f23
#REFACTORING by cg class: Class added: #logFacility
Class.st
--- a/Class.st	Wed Mar 01 10:39:08 2017 +0100
+++ b/Class.st	Wed Mar 01 10:39:27 2017 +0100
@@ -4097,6 +4097,42 @@
     ^ self theMetaclass includesSelector:#start
 !
 
+logFacility
+    "the 'log facility';
+     this is used by the Logger both as a prefix to the log message, 
+     and maybe (later) used to filter and/or control per-facility log thresholds.
+     The default here is to base the facility on the package:
+     if the class is anywhere in the base ST/X system, 'STX' is returned as facility.
+     Otherwise, the last component of the package name is returned."
+     
+    |pkg|
+
+    ((pkg := self package ? '???') startsWith:'stx:') ifTrue:[
+        ^ 'STX'
+    ].
+    ^ pkg copyFrom:((pkg lastIndexOf:$:) + 1)
+
+    "
+     Array logFacility
+     Array class logFacility
+     Class new logFacility
+     Behavior new logFacility
+
+     Expecco::Browser logFacility
+     Workflow::Executor logFacility
+
+     Array package
+     Array class package
+     Class new package
+     Behavior new package
+
+     Expecco::Browser package
+     Workflow::Executor package
+    "
+
+    "Created: / 01-03-2017 / 10:32:39 / cg"
+!
+
 methodsForWhich:aFilter
     "return a collection of methods (both class and inst) for which aFilter returns true"