Software / code / prosody
Comparison
util/logger.lua @ 716:d61eabc678a6
util/logger: setwriter now returns the old writer on success
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 14 Jan 2009 23:04:16 +0500 |
| parent | 615:4ae3e81513f3 |
| child | 758:b1885732e979 |
comparison
equal
deleted
inserted
replaced
| 715:beec1eb7d9c6 | 716:d61eabc678a6 |
|---|---|
| 61 end | 61 end |
| 62 end | 62 end |
| 63 end | 63 end |
| 64 | 64 |
| 65 function setwriter(f) | 65 function setwriter(f) |
| 66 if not f then outfunction = nil; return true, nil; end | 66 local old_func = outfunction; |
| 67 if not f then outfunction = nil; return true, old_func; end | |
| 67 local ok, ret = pcall(f, "logger", "info", "Switched logging output successfully"); | 68 local ok, ret = pcall(f, "logger", "info", "Switched logging output successfully"); |
| 68 if ok then | 69 if ok then |
| 69 outfunction = f; | 70 outfunction = f; |
| 71 ret = old_func; | |
| 70 end | 72 end |
| 71 return ok, ret; | 73 return ok, ret; |
| 72 end | 74 end |
| 73 | 75 |
| 74 return _M; | 76 return _M; |