Merge pull request #105 from blueyed/awful-util-deprecate-once-per-traceback
awful.util.deprecate: display deprecations only once
This commit is contained in:
commit
8fa1309279
|
@ -17,6 +17,7 @@ local type = type
|
||||||
local rtable = table
|
local rtable = table
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local string = string
|
local string = string
|
||||||
|
local glib = require("lgi").GLib
|
||||||
local capi =
|
local capi =
|
||||||
{
|
{
|
||||||
awesome = awesome,
|
awesome = awesome,
|
||||||
|
@ -30,13 +31,21 @@ util.table = {}
|
||||||
|
|
||||||
util.shell = os.getenv("SHELL") or "/bin/sh"
|
util.shell = os.getenv("SHELL") or "/bin/sh"
|
||||||
|
|
||||||
|
local displayed_deprecations = {}
|
||||||
|
--- Display a deprecation notice, but only once per traceback.
|
||||||
|
-- @param see Optional message to a new method / function to use.
|
||||||
function util.deprecate(see)
|
function util.deprecate(see)
|
||||||
|
local tb = debug.traceback()
|
||||||
|
local tbhash = glib.String():append(tb):hash()
|
||||||
|
if displayed_deprecations[tbhash] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
displayed_deprecations[tbhash] = true
|
||||||
io.stderr:write("W: awful: function is deprecated")
|
io.stderr:write("W: awful: function is deprecated")
|
||||||
if see then
|
if see then
|
||||||
io.stderr:write(", see " .. see)
|
io.stderr:write(", see " .. see)
|
||||||
end
|
end
|
||||||
io.stderr:write("\n")
|
io.stderr:write("\n" .. tb .. "\n")
|
||||||
io.stderr:write(debug.traceback())
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Strip alpha part of color.
|
--- Strip alpha part of color.
|
||||||
|
|
Loading…
Reference in New Issue