Software /
code /
verse
Changeset
125:b46921de1e03
verse: Add verse.log() to log a message using the default logger. Also add verse.set_error_handler() to, er, set an error handler.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 13 Sep 2010 14:07:41 +0100 |
parents | 124:3659ba3b8dfa |
children | 126:fa3ddadb8364 |
files | init.lua |
diffstat | 1 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/init.lua Sun Sep 12 17:49:01 2010 +0100 +++ b/init.lua Mon Sep 13 14:07:41 2010 +0100 @@ -27,6 +27,23 @@ verse.add_task = require "util.timer".add_task; +verse.logger = logger.init; +verse.log = verse.logger("verse"); + +function verse.set_logger(logger) + verse.log = logger("verse"); + server.setlogger(logger); +end + +local function error_handler(err) + verse.log("error", "Error: %s", err); + verse.log("error", "Traceback: %s", debug.traceback()); +end + +function verse.set_error_handler(new_error_handler) + error_handler = new_error_handler; +end + function verse.loop() return server.loop(); end @@ -35,12 +52,6 @@ return server.setquitting(true); end -verse.logger = logger.init; - -function verse.set_logger(logger) - server.setlogger(logger); -end - function stream:connect(connect_host, connect_port) connect_host = connect_host or "localhost"; connect_port = tonumber(connect_port) or 5222;