mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
Add Object.py and log.py
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
751afbe93d
commit
36aac73b5d
3 changed files with 41 additions and 1 deletions
17
tools/python/jwutils/Object.py
Normal file
17
tools/python/jwutils/Object.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import jwutils.log
|
||||||
|
|
||||||
|
class Object(object): # export
|
||||||
|
|
||||||
|
def __init__():
|
||||||
|
self.log_level = jwutils.log.NOTICE
|
||||||
|
|
||||||
|
def log(self, prio, *args):
|
||||||
|
if prio <= self.log_level:
|
||||||
|
msg = ""
|
||||||
|
for count, thing in enumerate(args):
|
||||||
|
msg += ' ' + str(thing)
|
||||||
|
if len(msg):
|
||||||
|
print msg[1:]
|
||||||
|
|
||||||
|
def debug(self, *args):
|
||||||
|
self.log(DEBUG, args)
|
||||||
|
|
@ -51,7 +51,8 @@ class ShuntingYard(object): # export
|
||||||
|
|
||||||
def token_string(self):
|
def token_string(self):
|
||||||
r = ""
|
r = ""
|
||||||
for k, v in self.__ops.iteritems():
|
for k in sorted(self.__ops):
|
||||||
|
v = self.__ops[k]
|
||||||
buf = ", \"" + k
|
buf = ", \"" + k
|
||||||
if v.nargs == 1:
|
if v.nargs == 1:
|
||||||
if k[len(k)-1].isalnum():
|
if k[len(k)-1].isalnum():
|
||||||
|
|
|
||||||
22
tools/python/jwutils/log.py
Normal file
22
tools/python/jwutils/log.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import syslog
|
||||||
|
|
||||||
|
EMERG = syslog.LOG_EMERG
|
||||||
|
ALER = syslog.LOG_ALERT
|
||||||
|
CRIT = syslog.LOG_CRIT
|
||||||
|
ERR = syslog.LOG_ERR
|
||||||
|
WARNING = syslog.LOG_WARNING
|
||||||
|
NOTICE = syslog.LOG_NOTICE
|
||||||
|
INFO = syslog.LOG_INFO
|
||||||
|
DEBUG = syslog.LOG_DEBUG
|
||||||
|
DEVEL = syslog.LOG_DEBUG + 1
|
||||||
|
OFF = DEVEL + 1
|
||||||
|
|
||||||
|
level = NOTICE
|
||||||
|
|
||||||
|
def log(prio, *args): # export
|
||||||
|
if prio <= level:
|
||||||
|
msg = ""
|
||||||
|
for count, thing in enumerate(args):
|
||||||
|
msg += ' ' + str(thing)
|
||||||
|
if len(msg):
|
||||||
|
print msg[1:]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue