Explorar el Código

Some log bugfixes

Cammy hace 6 años
padre
commit
7b38e3475f
Se han modificado 3 ficheros con 21 adiciones y 9 borrados
  1. 11 3
      pyinstalive/auth.py
  2. 7 3
      pyinstalive/downloader.py
  3. 3 3
      pyinstalive/logger.py

+ 11 - 3
pyinstalive/auth.py

@@ -97,15 +97,23 @@ def login(username, password, show_cookie_expiry, force_use_login_args):
 
 	except ClientLoginError as e:
 		log_seperator()
-		log_error('Could not login: {:s}.\n[E] {:s}\n\n{:s}'.format(json.loads(e.error_response).get("error_title", "Error title not available."), json.loads(e.error_response).get("message", "Not available"), e.error_response))
+		log_error('Could not login: {:s}.'.format(json.loads(e.error_response).get("error_title", "Error title not available.")))
+		log_error('{:s}'.format(json.loads(e.error_response).get("message", "Not available")))
+		log_error('{:s}'.format(e.error_response))
 		log_seperator()
 		sys.exit(9)
 	except ClientError as e:
 		log_seperator()
 		try:
-			log_error('Unexpected exception: {0!s}\n[E] Message: {1!s}\n[E] Code: {2:d}\n\n[E] Full response:\n{3!s}\n'.format(e.msg, json.loads(e.error_response).get("message", "Additional error information not available."), e.code, e.error_response))
+			log_error('Unexpected exception: {0!s}'.format(e.msg))
+			log_error('Message: {1!s}'.format(json.loads(e.error_response).get("message", "Additional error information not available.")))
+			log_error('Code: {2:d}'.format(e.code))
+			log_error('Full response:\n{3!s}'.format(e.error_response))
+			log_whiteline()
 		except Exception as ee:
-			log_error('An error occurred while trying to handle a previous exception.\n[E] 1: {:s}\n[E] 2: {:s}'.format(str(e), str(ee)))
+			log_error('An error occurred while trying to handle a previous exception.')
+			log_error('1: {:s}'.format(str(e)))
+			log_error('2: {:s}'.format(str(ee)))
 			if "getaddrinfo failed" in str(ee):
 				log_error('Could not resolve host, check your internet connection.')
 			if "timed out" in str(ee):

+ 7 - 3
pyinstalive/downloader.py

@@ -142,7 +142,9 @@ def download_livestream(broadcast):
 				log_error('An error occurred while downloading comments: {:s}'.format(str(e)))
 		broadcast_downloader.run()
 		log_seperator()
-		log_info_green('The livestream has ended.\n[I] Download duration : {}\n[I] Stream duration   : {}\n[I] Missing (approx.) : {}'.format(get_stream_duration(int(settings.current_time)), get_stream_duration(broadcast.get('published_time')), get_stream_duration(int(settings.current_time), broadcast)))
+		log_info_green('Download duration : {}'.format(get_stream_duration(int(settings.current_time))))
+		log_info_green('Stream duration   : {}'.format(get_stream_duration(broadcast.get('published_time'))))
+		log_info_green('Missing (approx.) : {}'.format(get_stream_duration(int(settings.current_time), broadcast)))
 		log_seperator()
 		stitch_video(broadcast_downloader, broadcast, comment_thread_worker)
 	except KeyboardInterrupt:
@@ -201,7 +203,8 @@ def stitch_video(broadcast_downloader, broadcast, comment_thread_worker):
 			log_seperator()
 			sys.exit(0)
 		except ValueError as e:
-			log_error('Could not stitch downloaded files: {:s}\n[E] Likely the download duration was too short and no temp files were saved.'.format(str(e)))
+			log_error('Could not stitch downloaded files: {:s}'.format(str(e)))
+			log_error('Likely the download duration was too short and no temp files were saved.')
 			log_seperator()
 			try:
 			    os.remove(os.path.join(live_folder_path, 'folder.lock'))
@@ -240,7 +243,8 @@ def get_user_info(user_to_download):
 		log_seperator()
 		sys.exit(1)
 	except ClientThrottledError as cte:
-		log_error('Could not get user info for "{:s}": {:d} {:s}\n[E] You are making too many requests at this time.'.format(user_to_download, cte.code, str(cte)))
+		log_error('Could not get user info for "{:s}": {:d} {:s}.'.format(user_to_download, cte.code, str(cte)))
+		log_error('You are making too many requests at this time.')
 		log_seperator()
 		sys.exit(1)
 	except ClientError as ce:

+ 3 - 3
pyinstalive/logger.py

@@ -73,7 +73,7 @@ def log_warn(string):
 	if settings.log_to_file == 'True':
 		try:
 			with open("pyinstalive{:s}.log".format("_" + settings.user_to_download if len(settings.user_to_download) > 0 else ".default"),"a+") as f:
-				f.write("[I] {:s}\n".format(string))
+				f.write("[W] {:s}\n".format(string))
 				f.close()
 		except:
 			pass
@@ -87,7 +87,7 @@ def log_error(string):
 	if settings.log_to_file == 'True':
 		try:
 			with open("pyinstalive{:s}.log".format("_" + settings.user_to_download if len(settings.user_to_download) > 0 else ".default"),"a+") as f:
-				f.write("[I] {:s}\n".format(string))
+				f.write("[E] {:s}\n".format(string))
 				f.close()
 		except:
 			pass
@@ -109,7 +109,7 @@ def log_plain(string):
 	if settings.log_to_file == 'True':
 		try:
 			with open("pyinstalive{:s}.log".format("_" + settings.user_to_download if len(settings.user_to_download) > 0 else ".default"),"a+") as f:
-				f.write("    {:s}\n".format(string))
+				f.write("{:s}\n".format(string))
 				f.close()
 		except:
 			pass