resgen_log.py
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#########################################################################
# MTK Resource Generation System
# Module: resgen_offline_param
# Description: Provide unified log interface for mtk resource generation
# system
#########################################################################
import sys
import os
import traceback
import shutil
import time
#import threading
import thread
####################################################
# Resgen Log APIs
####################################################
class ResgenLog:
@staticmethod
def d(tag, message):
ResgenLog.log('[D]', tag, message)
@staticmethod
def v(tag, message):
ResgenLog.log('[V]', tag, message)
@staticmethod
def w(tag, message):
ResgenLog.log('[W]', tag, message)
@staticmethod
def e(tag, message):
ResgenLog.log('[E]', tag, 'Error!! ' + message)
@staticmethod
def getTimeStampeMark():
return time.strftime('[%H:%M:%S]', time.localtime())
@staticmethod
def log(debugLevelMark, tag, message):
print(debugLevelMark + ResgenLog.getTimeStampeMark() + ResgenLog.getThreadMark() + '[PY:'+ tag + ']'+ message)
@staticmethod
def getThreadMark():
# Since thread class is deplicated from python 2.7, if we change the runtime form 2.5/2.6 to 2.7,
# the implementation should changed to the following one
# threadId = 0
# threadObj = threading.currentThread()
# if not threadObj is None:
# theadId = threadObj.ident
# return '[' + str(threadId) + ']'
return '[TID:' + str(thread.get_ident()) + ']'