Created
March 30, 2012 03:34
-
-
Save do-aki/2246245 to your computer and use it in GitHub Desktop.
fluent.logger_lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local logger = require 'fluent.logger' | |
logger.connect() | |
logger.post('test.test', {message='data'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local os = require 'os' | |
local msgpack = require 'msgpack' | |
local socket = require 'socket' | |
module('fluent.logger') | |
local fluent = nil | |
function connect(host, port) | |
fluent = socket.connect(host or '127.0.0.1', port or 24224) | |
end | |
function post(tag, data) | |
local p = msgpack.Packer() | |
local msg = p:pack({tag, os.time(), data}) | |
fluent:send(msg) | |
end | |
function close() | |
fluent:close() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment