diff options
author | moteus <mimir@newmail.ru> | 2013-12-26 15:34:58 +0400 |
---|---|---|
committer | moteus <mimir@newmail.ru> | 2013-12-26 15:34:58 +0400 |
commit | 5982fd74baad6cdee2c536203afe6c435a2d02e9 (patch) | |
tree | e8b7e667ab4160ad95e9409bc7bd826e69fbc9ff /README.md | |
parent | 92ec624951de2d344b28eb5262a3534822f6d6a7 (diff) | |
download | lua-llthreads2-5982fd74baad6cdee2c536203afe6c435a2d02e9.tar.gz lua-llthreads2-5982fd74baad6cdee2c536203afe6c435a2d02e9.tar.bz2 lua-llthreads2-5982fd74baad6cdee2c536203afe6c435a2d02e9.zip |
Add. set_logger function allow logging errors (crash Lua VM) in current llthread's threads.
``` Lua
local llthreads = require "llthreads"
local LOG = require"log".new(
require "log.writer.net.zmq".new("tcp://127.0.0.1:5555")
)
llthread.set_logger(function(msg) LOG.error(msg) end)
```
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -15,6 +15,26 @@ This is full dropin replacement for [llthreads](https://github.com/Neopallium/lu | |||
15 | ##Additional | 15 | ##Additional |
16 | * thread:join() method support zero timeout to check if thread alive | 16 | * thread:join() method support zero timeout to check if thread alive |
17 | * thread:join() method support arbitrary timeout on Windows platform | 17 | * thread:join() method support arbitrary timeout on Windows platform |
18 | * set_logger function allow logging errors (crash Lua VM) in current llthread's threads | ||
18 | 19 | ||
19 | [](https://bitdeli.com/free "Bitdeli Badge") | 20 | [](https://bitdeli.com/free "Bitdeli Badge") |
20 | 21 | ||
22 | |||
23 | ##Usage | ||
24 | |||
25 | ### Use custom logger | ||
26 | In this example I use [lua-log](https://github.com/moteus/lua-log) library. | ||
27 | ``` Lua | ||
28 | -- This is child thread. | ||
29 | local llthreads = require "llthreads" | ||
30 | -- Send logs using ZMQ | ||
31 | local LOG = require"log".new( | ||
32 | require "log.writer.net.zmq".new("tcp://127.0.0.1:5555") | ||
33 | ) | ||
34 | llthread.set_logger(function(msg) LOG.error(msg) end) | ||
35 | |||
36 | ... | ||
37 | |||
38 | -- This error with traceback will be passed to logger | ||
39 | error("SOME ERROR") | ||
40 | ``` | ||