summaryrefslogtreecommitdiff
path: root/lua/telescope/log.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-08-20 23:41:53 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-08-20 23:41:53 -0400
commitcfddae42f59eacbd792a8853be089f4711bbf4ba (patch)
tree9033de9a43822a63544244559380729b8f3d84bf /lua/telescope/log.lua
parent96cac0a8c861d5cdb1bb7765cc2d20e47ebb7885 (diff)
WIP: Actually get the UI to work and add some tests
Diffstat (limited to 'lua/telescope/log.lua')
-rw-r--r--lua/telescope/log.lua85
1 files changed, 3 insertions, 82 deletions
diff --git a/lua/telescope/log.lua b/lua/telescope/log.lua
index fb3d712..a9bc2b0 100644
--- a/lua/telescope/log.lua
+++ b/lua/telescope/log.lua
@@ -1,83 +1,4 @@
--- https://raw.githubusercontent.com/rxi/log.lua/master/log.lua
--- log.lua
---
--- Copyright (c) 2016 rxi
---
--- This library is free software; you can redistribute it and/or modify it
--- under the terms of the MIT license. See LICENSE for details.
---
-
-local log = { _version = "0.1.0" }
-
-log.usecolor = true
-log.outfile = vim.fn.stdpath('data') .. '/telescope.log'
-log.console = false
-log.level = "trace"
-
-
-local modes = {
- { name = "trace", color = "\27[34m", },
- { name = "debug", color = "\27[36m", },
- { name = "info", color = "\27[32m", },
- { name = "warn", color = "\27[33m", },
- { name = "error", color = "\27[31m", },
- { name = "fatal", color = "\27[35m", },
+return require('plenary.log').new {
+ plugin = 'telescope',
+ level = 'debug',
}
-
-
-local levels = {}
-for i, v in ipairs(modes) do
- levels[v.name] = i
-end
-
-
-local round = function(x, increment)
- increment = increment or 1
- x = x / increment
- return (x > 0 and math.floor(x + .5) or math.ceil(x - .5)) * increment
-end
-
-for i, x in ipairs(modes) do
- local nameupper = x.name:upper()
- log[x.name] = function(...)
- -- Return early if we're below the log level
- if i < levels[log.level] then
- return
- end
-
- local passed = {...}
- local fmt = table.remove(passed, 1)
- local inspected = {}
- for _, v in ipairs(passed) do
- table.insert(inspected, vim.inspect(v))
- end
- local msg = string.format(fmt, unpack(inspected))
- local info = debug.getinfo(2, "Sl")
- local lineinfo = info.short_src .. ":" .. info.currentline
-
- -- Output to console
- if log.console then
- print(string.format("%s[%-6s%s]%s %s: %s",
- log.usecolor and x.color or "",
- nameupper,
- os.date("%H:%M:%S"),
- log.usecolor and "\27[0m" or "",
- lineinfo,
- msg))
- end
-
- -- Output to log file
- if log.outfile then
- local fp = io.open(log.outfile, "a")
- local str = string.format("[%-6s%s] %s: %s\n",
- nameupper, os.date(), lineinfo, msg)
- fp:write(str)
- fp:close()
- end
-
- end
-end
-
-log.info("Logger Succesfully Loaded")
-
-return log