[sr-dev] git:master: mod_python: Changed Loggers.py to use recent changes ( python abstraction layers).
Konstantin Mosesov
ez at voipgroup.org.ua
Tue Dec 11 15:29:11 CET 2012
Module: sip-router
Branch: master
Commit: cc9b6cad1130891c54b94b44bebb2b6cdf397b1a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cc9b6cad1130891c54b94b44bebb2b6cdf397b1a
Author: Konstantin Mosesov <ez at voipgroup.org.ua>
Committer: Konstantin Mosesov <ez at voipgroup.org.ua>
Date: Tue Dec 11 16:29:30 2012 +0200
mod_python: Changed Loggers.py to use recent changes (python abstraction layers).
---
modules/app_python/python_examples/Loggers.py | 70 ++++++++++++++++++++-----
1 files changed, 56 insertions(+), 14 deletions(-)
diff --git a/modules/app_python/python_examples/Loggers.py b/modules/app_python/python_examples/Loggers.py
index 9f8b706..8ae2ed0 100644
--- a/modules/app_python/python_examples/Loggers.py
+++ b/modules/app_python/python_examples/Loggers.py
@@ -2,13 +2,16 @@
"""
Script for logging test.
- 2012.12.03: Created by: Konstantin M. <evilzluk at gmail.com>
+ Added: 2012-12-03: Created by: Konstantin M. <evilzluk at gmail.com>
+ Changed: 2012-12-11: Changed code to use Router.Logger
+ Changed: 2012-12-11: Changed code to use Router.Ranks
"""
-import Router
+import Router.Logger as Logger
+import Router.Ranks as Ranks
"""
- Module Properties:
+ Router.Logger Module Properties:
Log Levels:
L_ALERT
L_BUG
@@ -23,7 +26,7 @@ import Router
Log Facilities:
DEFAULT_FACILITY
- Module Methods:
+ Router.Logger Module Methods:
LM_GEN1(self, int log_level, str msg)
LM_GEN2(self, int log_facility, int log_level, str msg)
LM_ALERT(self, str msg)
@@ -35,6 +38,20 @@ import Router
LM_DBG(self, str msg)
+ Router.Ranks Module Properties:
+ PROC_MAIN
+ PROC_TIMER
+ PROC_RPC
+ PROC_FIFO
+ PROC_TCP_MAIN
+ PROC_UNIXSOCK
+ PROC_ATTENDANT
+ PROC_INIT
+ PROC_NOCHLDINIT
+ PROC_SIPINIT
+ PROC_SIPRPC
+ PROC_MIN
+
"""
class Loggers:
@@ -45,19 +62,44 @@ class Loggers:
def __del__(self):
pass
- def child_init(self, y):
+ def child_init(self, rank):
+ if rank == Ranks.PROC_MAIN:
+ Logger.LM_ERR("rank is PROC_MAIN")
+ elif rank == Ranks.PROC_TIMER:
+ Logger.LM_ERR("rank is PROC_TIMER")
+ elif rank == Ranks.PROC_RPC:
+ Logger.LM_ERR("rank is PROC_RPC")
+ elif rank == Ranks.PROC_FIFO:
+ Logger.LM_ERR("rank is PROC_FIFO")
+ elif rank == Ranks.PROC_TCP_MAIN:
+ Logger.LM_ERR("rank is PROC_TCP_MAIN")
+ elif rank == Ranks.PROC_UNIXSOCK:
+ Logger.LM_ERR("rank is PROC_UNIXSOCK")
+ elif rank == Ranks.PROC_ATTENDANT:
+ Logger.LM_ERR("rank is PROC_ATTENDANT")
+ elif rank == Ranks.PROC_INIT:
+ Logger.LM_ERR("rank is PROC_INIT")
+ elif rank == Ranks.PROC_NOCHLDINIT:
+ Logger.LM_ERR("rank is PROC_NOCHLDINIT")
+ elif rank == Ranks.PROC_SIPINIT:
+ Logger.LM_ERR("rank is PROC_SIPINIT")
+ elif rank == Ranks.PROC_SIPRPC:
+ Logger.LM_ERR("rank is PROC_SIPRPC")
+ elif rank == Ranks.PROC_MIN:
+ Logger.LM_ERR("rank is PROC_MIN")
+
return 0
def TestLoggers(self, msg, args):
- Router.LM_GEN1(Router.L_INFO, "Loggers.py: LM_GEN1: msg: %s" % str(args))
- Router.LM_GEN2(Router.L_INFO, Router.DEFAULT_FACILITY, "Loggers.py: LM_GEN2: msg: %s" % str(args))
- Router.LM_ALERT( "Loggers.py: LM_ALERT: msg: %s" % str(args))
- Router.LM_CRIT( "Loggers.py: LM_CRIT: msg: %s" % str(args))
- Router.LM_ERR( "Loggers.py: LM_ERR: msg: %s" % str(args))
- Router.LM_WARN( "Loggers.py: LM_WARN: msg: %s" % str(args))
- Router.LM_NOTICE( "Loggers.py: LM_NOTICE: msg: %s" % str(args))
- Router.LM_INFO( "Loggers.py: LM_INFO: msg: %s" % str(args))
- Router.LM_DBG( "Loggers.py: LM_DBG: msg: %s" % str(args))
+ Logger.LM_GEN1(Logger.L_INFO, "Loggers.py: LM_GEN1: msg: %s" % str(args))
+ Logger.LM_GEN2(Logger.L_INFO, Logger.DEFAULT_FACILITY, "Loggers.py: LM_GEN2: msg: %s" % str(args))
+ Logger.LM_ALERT( "Loggers.py: LM_ALERT: msg: %s" % str(args))
+ Logger.LM_CRIT( "Loggers.py: LM_CRIT: msg: %s" % str(args))
+ Logger.LM_ERR( "Loggers.py: LM_ERR: msg: %s" % str(args))
+ Logger.LM_WARN( "Loggers.py: LM_WARN: msg: %s" % str(args))
+ Logger.LM_NOTICE( "Loggers.py: LM_NOTICE: msg: %s" % str(args))
+ Logger.LM_INFO( "Loggers.py: LM_INFO: msg: %s" % str(args))
+ Logger.LM_DBG( "Loggers.py: LM_DBG: msg: %s" % str(args))
return 1
def mod_init():
More information about the sr-dev
mailing list