{"id":13681967,"url":"https://github.com/smartpde/debuglog","last_synced_at":"2025-04-30T06:33:03.913Z","repository":{"id":161688876,"uuid":"532642762","full_name":"smartpde/debuglog","owner":"smartpde","description":"Debug logging for Neovim plugin developers","archived":false,"fork":false,"pushed_at":"2024-01-18T11:08:48.000Z","size":18,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-02T13:33:12.330Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartpde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-04T19:51:51.000Z","updated_at":"2024-04-03T21:37:02.000Z","dependencies_parsed_at":"2024-01-14T15:22:02.721Z","dependency_job_id":"d5a95bf6-9165-4a08-a206-c95c4b200fec","html_url":"https://github.com/smartpde/debuglog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartpde%2Fdebuglog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartpde%2Fdebuglog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartpde%2Fdebuglog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartpde%2Fdebuglog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartpde","download_url":"https://codeload.github.com/smartpde/debuglog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224201780,"owners_count":17272644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:01:38.495Z","updated_at":"2024-11-12T01:30:45.117Z","avatar_url":"https://github.com/smartpde.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# debuglog for Neovim plugin developers\n\n`debuglog` is made for Neovim plugin developers to debug the plugin locally, or collect\ndebugging info from users.\n\nWith `debuglog`, you leave the debug statements in the code. By default, nothing is logged,\nbut you can enable the loggers selectively.\n\nThe users of your plugin do _not_ need the `debuglog` to be installed. All logging is done\nthrough the tiny [shim](#shim) file that you include in your plugin. Without the full\n`debuglog` module, everything is a no-op.\n\n## Installation\n\nTo install the plugin with [packer.nvim](https://github.com/wbthomason/packer.nvim):\n\n```lua\nuse {\"smartpde/debuglog\"}\n```\n\nOnce installed, call the `setup()` function to register various commands:\n```lua\nrequire(\"debuglog\").setup()\n```\n\n## Shim\n\n`debuglog` is an optional dependency of your plugin, therefore you must install the tiny\nshim file [dlog.lua](https://github.com/smartpde/debuglog/blob/main/dlog.lua) into your\nplugin's directory. The shim checks if the full `debuglog` module is present, and turns\nall logging into a no-op otherwise.\n\nThere is a simple command to copy the shim file for you:\n\n```\n:DebugLogInstallShim \u003cpath to plugin_dir/lua\u003e\n\nFor example:\n:DebugLogInstallShim ~/projects/my_awesome_plugin/lua\n```\n\nYou can of course copy the file any other way.\n\n## Writing debug statements\n\nNote that all debug loggers must be created using the `dlog` shim module:\n\n```lua\n-- Enable logging by running \":DebugLogEnable *\" command first.\n\nlocal dlog = require(\"dlog\")\nlocal logger1 = dlog.logger(\"some_logger\")\nlocal logger2 = dlog.logger(\"another_logger\")\n\nlogger1(\"This is from %s\", \"some_logger\")\nlogger1(\"This is also from %s\", \"some_logger\")\nlogger2(\"And this is from %s\", \"another_logger\")\n\n-- you can also check if the logger is enabled if the value to print\n-- is expensive to get\nif dlog.is_enabled(\"logger1\") then\n  logger1(\"Print some heavy string: %s\", \"heavy string\")\nend\n```\n\nYou can create many named loggers, the logger name will be attached to all its\nmessages. Additionally, log statements in the vim `:messages` will be nicely colored\nfor easier identification:\n\n\u003cimg width=\"831\" alt=\"image\" src=\"https://user-images.githubusercontent.com/16953692/188493270-039a3bf8-34f6-4664-8a87-85d9b58c5003.png\"\u003e\n\nThe loggers use standard Lua's [string.format()](https://www.lua.org/pil/20.html).\n\n## Enable and disable logging\n\nBy default, nothing is logged unless you enable the loggers. To do so you can use the plugin\ncommands:\n\n- Enable all loggers:\n\n  ```\n  :DebugLogEnable *\n  ```\n\n- Enable loggers selectively:\n\n  ```\n  :DebugLogEnable some_logger,another_logger\n  ```\n\n  Note that enabling new loggers disables all previous ones.\n\n- Disable all logging:\n\n  ```\n  :DebugLogDisable\n  ```\n\nYou can also use the corresponding Lua functions:\n\n```lua\nlocal debuglog = require(\"debuglog\")\ndebuglog.enable(\"*\")\ndebuglog.disable()\n```\n\n## Logging to file\n\nBy default, logs are written only to the `:messages` console. You can also enable logging\nto a file:\n\n- With user command:\n\n  ```\n  :DebugLogEnableFileLogging\n  ```\n\n- With Lua:\n\n  ```lua\n  require(\"debuglog\").set_config({\n    log_to_file = true,\n    log_to_console = true,\n  })\n  ```\n\nThe log file path will be printed out. You can also use the following command\nopen the log file in Neovim:\n\n```\n:DebugLogOpenFileLog\n```\n\nOr get the log file path in Lua:\n\n```lua\nrequire(\"debuglog\").log_file_path()\n```\n\nTo disable file logging run:\n```\n:DebugLogDisableFileLogging\n```\n\n## Configuration options\n\nThe full list of configuration options with their defaults:\n\n```lua\nrequire(\"debuglog\").setup({\n  log_to_console = true,\n  log_to_file = false,\n  -- The highlight group for printing the time column in console\n  time_hl_group = \"Comment\",\n})\n```\n\nThe options can also be modified by calling the `set_config(opts)` function\nafter the setup.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartpde%2Fdebuglog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartpde%2Fdebuglog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartpde%2Fdebuglog/lists"}