From 3f91484791e6be1610633f70b72d1725d803faf4 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 21 Jul 2015 11:31:27 +0800 Subject: [PATCH] user log service --- examples/config.userlog | 18 ++++++++++++++++++ examples/userlog.lua | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 examples/config.userlog create mode 100644 examples/userlog.lua diff --git a/examples/config.userlog b/examples/config.userlog new file mode 100644 index 00000000..97bef6ef --- /dev/null +++ b/examples/config.userlog @@ -0,0 +1,18 @@ +root = "./" +thread = 8 +logger = "userlog" +logservice = "snlua" +logpath = "." +harbor = 1 +address = "127.0.0.1:2526" +master = "127.0.0.1:2013" +start = "main" -- main script +bootstrap = "snlua bootstrap" -- The service for bootstrap +standalone = "0.0.0.0:2013" +luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua" +lualoader = "lualib/loader.lua" +-- preload = "./examples/preload.lua" -- run preload.lua before every lua service run +snax = root.."examples/?.lua;"..root.."test/?.lua" +-- snax_interface_g = "snax_g" +cpath = root.."cservice/?.so" +-- daemon = "./skynet.pid" diff --git a/examples/userlog.lua b/examples/userlog.lua new file mode 100644 index 00000000..55aa0952 --- /dev/null +++ b/examples/userlog.lua @@ -0,0 +1,15 @@ +local skynet = require "skynet" +require "skynet.manager" + +skynet.register_protocol { + name = "text", + id = skynet.PTYPE_TEXT, + unpack = skynet.tostring, + dispatch = function(_, address, msg) + print(string.format("%x(%.2f): %s", address, skynet.time(), msg)) + end +} + +skynet.start(function() + skynet.register ".logger" +end) \ No newline at end of file