forked from rjpcomputing/luaforwindows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket.lua
More file actions
executable file
·35 lines (27 loc) · 1.17 KB
/
socket.lua
File metadata and controls
executable file
·35 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-------------------------------------------------------------------------------
-- Sends the logging information through a socket using luasocket
--
-- @author Thiago Costa Ponte ([email protected])
--
-- @copyright 2004-2011 Kepler Project
--
-------------------------------------------------------------------------------
require"logging"
local socket = require"socket"
function logging.socket(address, port, logPattern)
return logging.new( function(self, level, message)
local s = logging.prepareLogMsg(logPattern, os.date(), level, message)
local socket, err = socket.connect(address, port)
if not socket then
return nil, err
end
local cond, err = socket:send(s)
if not cond then
return nil, err
end
socket:close()
return true
end
)
end
return logging.socket