Skip to content

Commit

Permalink
Adding traceback info to the default error log (#176)
Browse files Browse the repository at this point in the history
* Update socketify.py

* Update socketify.py
  • Loading branch information
leunga1000 committed Jun 3, 2024
1 parent 293b2a9 commit 2a398a3
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/socketify/socketify.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uuid
from urllib.parse import parse_qs, quote_plus, unquote_plus
import logging
import traceback

from .native import ffi, lib
from .loop import Loop
Expand All @@ -33,7 +34,7 @@ def uws_missing_server_name(hostname, hostname_length, user_data):
handler(data)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception:\n %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -67,7 +68,7 @@ async def wrapper(app, instances, handler, ws):
if dispose:
app._ws_factory.dispose(instances)
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -89,7 +90,7 @@ def uws_websocket_drain_handler_with_extension(ws, user_data):
handler(ws)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -107,7 +108,7 @@ def uws_websocket_drain_handler(ws, user_data):
handler(ws)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -189,7 +190,7 @@ async def wrapper(
if dispose:
app._ws_factory.dispose(instances)
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -232,7 +233,7 @@ def uws_websocket_subscription_handler(
)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -279,7 +280,7 @@ def uws_websocket_subscription_handler_with_extension(
)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -312,7 +313,7 @@ async def wrapper(app, instances, handler, ws):
if dispose:
app._ws_factory.dispose(instances)
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -335,7 +336,7 @@ def uws_websocket_open_handler_with_extension(ws, user_data):
handler(ws)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -354,7 +355,7 @@ def uws_websocket_open_handler(ws, user_data):
handler(ws)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -396,7 +397,7 @@ async def wrapper(app, instances, handler, ws, data):
if dispose:
app._ws_factory.dispose(instances)
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -430,7 +431,7 @@ def uws_websocket_message_handler_with_extension(

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -458,7 +459,7 @@ def uws_websocket_message_handler(ws, message, length, opcode, user_data):

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -497,7 +498,7 @@ async def wrapper(app, instances, handler, ws, data):
if dispose:
app._ws_factory.dispose(instances)
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -524,7 +525,7 @@ def uws_websocket_pong_handler_with_extension(ws, message, length, user_data):
handler(ws, data)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -547,7 +548,7 @@ def uws_websocket_pong_handler(ws, message, length, user_data):
handler(ws, data)
except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -587,7 +588,7 @@ async def wrapper(app, instances, handler, ws, data):
if dispose:
app._ws_factory.dispose(instances)
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -616,7 +617,7 @@ def uws_websocket_ping_handler_with_extension(ws, message, length, user_data):

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand All @@ -641,7 +642,7 @@ def uws_websocket_ping_handler(ws, message, length, user_data):

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -691,7 +692,7 @@ async def wrapper(app, instances, handler, ws, code, data, dispose):

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -737,7 +738,7 @@ async def wrapper(app, handler, ws, code, data):

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -779,7 +780,7 @@ async def wrapper(app, handler, ws, code, data):

except Exception as err:
logging.error(
"Uncaught Exception: %s" % str(err)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention


Expand Down Expand Up @@ -3420,7 +3421,7 @@ def trigger_error(self, error, response, request):
if self.error_handler is None:
try:
logging.error(
"Uncaught Exception: %s" % str(error)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention
response.write_status(500).end("Internal Error")
finally:
Expand All @@ -3437,7 +3438,7 @@ def trigger_error(self, error, response, request):
try:
# Error handler got an error :D
logging.error(
"Uncaught Exception: %s" % str(error)
"Uncaught Exception: %s" % traceback.format_exc()
) # just log in console the error to call attention
response.write_status(500).end("Internal Error")
finally:
Expand Down

0 comments on commit 2a398a3

Please sign in to comment.