Giter Club home page Giter Club logo

vlog.nvim's Introduction

vlog.nvim

A logger for neovim

Single file, no dependency, easy copy & paste log file to add to your neovim lua plugins.

Usage

-- Provides both `print` style and `string.format` style logging
log.info("I can pass", my_arg, "like I can for `print`")
log.fmt_info("I can pass %s arguments like `string.format`", my_arg)

-- Provides 
log.trace(...)
log.debug(...)
log.info(...)
log.warn(...)
log.error(...)
log.fatal(...)

-- and the corresponding
log.fmt_trace(...)
log.fmt_debug(...)
log.fmt_info(...)
log.fmt_warn(...)
log.fmt_error(...)
log.fmt_fatal(...)

Configuration

The following values are configurable:

local default_config = {
  -- Name of the plugin. Prepended to log messages
  plugin = 'vlog.nvim',

  -- Should print the output to neovim while running
  use_console = true,

  -- Should highlighting be used in console (using echohl)
  highlights = true,

  -- Should write to a file
  use_file = true,

  -- Any messages above this level will be logged.
  level = "trace",

  -- Level configuration
  modes = {
    { name = "trace", hl = "Comment", },
    { name = "debug", hl = "Comment", },
    { name = "info",  hl = "None", },
    { name = "warn",  hl = "WarningMsg", },
    { name = "error", hl = "ErrorMsg", },
    { name = "fatal", hl = "ErrorMsg", },
  },

  -- Can limit the number of decimals displayed for floats
  float_precision = 0.01,
}

Installation

There are two ways to install.

Standalone

The first is simply copying the zero-dependency log.lua file into your project. It is recommended that you place this file within a subdirectory of your lua project. After pasting into your project, change the values in the config table at the top of the file.

For example, for my_cool_plugin, you should place log.lua in my_cool_plugin/log.lua and require it with require('my_cool_plugin.log').

local log = require('my_cool_plugin.log')

log.info("Doing some logging")

Neovim Plugin

You can also install this as a plugin (to get any updates) by using your favorite neovim plugin manager.

After doing so, you can use log.new to generate a new logger for your plugin.

-- In my_plugin/log.lua
return require('vlog').new {
    plugin = 'my_cool_plugin',
}

-- In my_plug/other_file.lua
local log = require('my_plugin.log')

log.info("Doing some logging stuff")

vlog.nvim's People

Contributors

tjdevries avatar

Stargazers

ej shafran avatar Alexandre Pasmantier avatar 姚文强 avatar Hans Bignon K. Tognon avatar  avatar Erlang Parasu avatar Carlos Vigil-Vásquez avatar Daniel Lazar avatar Vladimir Kuznetsov avatar Chaitanya Sharma avatar Ivan Smirnov avatar Morteza NourelahiAlamdari avatar Mika Vilpas avatar Rishikesh Vaishnav avatar mg20400 avatar  avatar brokenbyte  avatar Daniel Tompkins avatar Bart avatar Chaz avatar Alejandro Virelles avatar Hecdin Farias avatar Pierre Bertet avatar neo451 avatar Federico Mengozzi avatar Chucongqing avatar Tyler Jang avatar  avatar likalium avatar Javed Khan avatar  avatar RJ Larson avatar Hung Tran avatar Guillaume Lagrange avatar Giuseppe Matheus avatar Jongwook Choi avatar David Meyer avatar  avatar Iurco Tiberiu-Iulian avatar Zhiya Luo avatar Furkan Üzümcü avatar Mike Wassmer avatar  avatar Robert A. Blankenship avatar Shawn Pande avatar james larisch avatar Laurynas Lazauskas avatar jinzhongjia avatar Yogesh avatar AFindex avatar kohane27 avatar Arkoprabho Chakraborti avatar EpiCanard avatar Harley avatar Matvey Bystrin avatar AYOUB EL MHAMDI avatar Jesus Alvarez avatar Tak avatar girishji avatar Pierre-Yves Douault avatar Soc Virnyl S. Estela avatar Mark avatar  avatar Daemon avatar Robert Audi avatar  avatar Srinesh Nisala avatar Mauricio Trajano avatar Viv Sedov avatar Elizabeth Marston avatar Matthieu Coudron avatar NAKAMURA Mitsuhiro avatar  avatar  avatar  avatar dcampos avatar piNkliNeAggression avatar Robert Verst avatar Danymat avatar Michael B avatar Jacob Vaverka avatar Ian McGaunn avatar Aliou Diallo avatar  avatar Marcelo Magalhães avatar .̶r̶̶ꝋꝋ̶̶̶𐌕 avatar David Kleingeld avatar Nathan Knowler avatar Alejandro avatar Joel Palmer avatar Mateusz Kadlubowski avatar Egor Dementyev avatar  avatar Ben Smith avatar  avatar Nils avatar Dicha Zelianivan Arkana avatar freddiehill avatar Beau avatar Rafał Camlet avatar

Watchers

James Cloos avatar Jongwook Choi avatar Wil Thomason avatar  avatar  avatar

vlog.nvim's Issues

vlog.new returns nil

Is it just me or is vlog.new returning nil? I feel like there should be a

    return obj

around here?

vlog.nvim/log.lua

Lines 147 to 149 in 300e43f

end
end
end

I added it myself for the local copy I have and it seems to be working as I expected to.

fmt_<log_level> throws an error

Steps to recreate:

  1. Add log.lua file to the project
  2. Create a lua file and add following content
local log = require('java.log')
log.fmt_info('hello %s', 'world')
  1. Run the file :luafile %

Error:

E5113: Error while calling lua chunk: /home/s1n7ax/Workspace/nvim-java/lua/java/log.lua:97: bad argument #1 to 'message_maker' (string expected, got nil)
stack traceback:
	[C]: in function 'message_maker'
	/home/s1n7ax/Workspace/nvim-java/lua/java/log.lua:97: in function 'fmt_info'
	test.lua:21: in main chunk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.