MCPcopy Create free account
hub / github.com/apache/cloudstack / createLogs

Method createLogs

tools/marvin/marvin/marvinLog.py:128–192  ·  view source on GitHub ↗

@Name : createLogs @Desc : Gets the Logger with file paths initialized and created @Inputs :test_module_name: Test Module Name to use for logs while creating log folder path log_cfg: Log Configuration provided inside of Conf

(self,
                   test_module_name=None,
                   log_cfg=None,
                   user_provided_logpath=None, use_temp_path=True)

Source from the content-addressed store, hash-verified

126 return self.__logFolderDir
127
128 def createLogs(self,
129 test_module_name=None,
130 log_cfg=None,
131 user_provided_logpath=None, use_temp_path=True):
132 '''
133 @Name : createLogs
134 @Desc : Gets the Logger with file paths initialized and created
135 @Inputs :test_module_name: Test Module Name to use for logs while
136 creating log folder path
137 log_cfg: Log Configuration provided inside of
138 Configuration
139 user_provided_logpath:LogPath provided by user
140 If user provided log path
141 is available, then one in cfg
142 will not be picked up.
143 use_temp_path: Boolean value which specifies either logs will
144 be prepended by random path or not.
145 @Output : SUCCESS\FAILED
146 '''
147 try:
148 temp_ts = time.strftime("%b_%d_%Y_%H_%M_%S", time.localtime())
149
150 if test_module_name is None:
151 temp_path = temp_ts + "_" + random_gen()
152 else:
153 temp_path = str(test_module_name) + "__" + str(temp_ts) + "_" + random_gen()
154
155 if user_provided_logpath:
156 temp_dir = os.path.join(user_provided_logpath, "MarvinLogs")
157 elif ((log_cfg is not None) and
158 ('LogFolderPath' in list(log_cfg.__dict__.keys())) and
159 (log_cfg.__dict__.get('LogFolderPath') is not None)):
160 temp_dir = os.path.join(log_cfg.__dict__.get('LogFolderPath'), "MarvinLogs")
161
162 if use_temp_path == True:
163 self.__logFolderDir = os.path.join(temp_dir, temp_path)
164 else:
165 if test_module_name == None:
166 self.__logFolderDir = temp_dir
167 else:
168 self.__logFolderDir = os.path.join(temp_dir, str(test_module_name))
169
170 print("\n==== Log Folder Path: %s All logs will be available here ====" % str(self.__logFolderDir))
171 os.makedirs(self.__logFolderDir)
172
173 '''
174 Log File Paths
175 1. FailedExceptionLog
176 2. RunLog contains the complete Run Information for Test Run
177 3. ResultFile contains the TC result information for Test Run
178 '''
179
180 tc_failed_exception_log = os.path.join(self.__logFolderDir, "failed_plus_exceptions.txt")
181 tc_run_log = os.path.join(self.__logFolderDir, "runinfo.txt")
182
183 if self.__setLogHandler(tc_run_log,
184 log_level=logging.DEBUG) != FAILED:
185 self.__setLogHandler(tc_failed_exception_log,

Callers 2

__initLoggingMethod · 0.95

Calls 6

__setLogHandlerMethod · 0.95
random_genFunction · 0.90
GetDetailExceptionInfoFunction · 0.90
keysMethod · 0.80
getMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected