Coder Social home page Coder Social logo

Logging needs attention about nvim-ide HOT 34 CLOSED

ldelossa avatar ldelossa commented on June 30, 2024
Logging needs attention

from nvim-ide.

Comments (34)

ldelossa avatar ldelossa commented on June 30, 2024 1

Here is an example in "workspace.lua"

self.config = vim.deepcopy(ide.config)

As you can see, you should be able to access config like a global with "require("ide").config". Im not sure why this wouldnt work for you.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024 1

I will give it a quick try but you might have to do it because I'm going away and won't be able to work on it.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

How can I get the log_level value from the config into the logger.lua file?
I tried to do require('ide') at the top of the logger file and then access the config table from that but it gave an error saying there was an error loading the module.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Hmm ok, i'll see if i might have been doing something wrong. thanks

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

After playing around with things I still can't get the require to work. The error it gives me is loop or previous error loading module 'ide' and I can't find anywhere where it would be a loop (unless I don't completely understand lua's require system).

from nvim-ide.

distek avatar distek commented on June 30, 2024

Hey @ldelossa I was looking in to this and I see what BeeverFeever was saying; There's a module dep loop when it comes to requiring 'ide' inside of logger due to the panels already requiring it.

I believe we talked about it before, but how would you feel about if, instead of obtaining a copy of the config in whichever modules need it, we global the config and copy in to it on init so we can just call IDEConfig.whatever instead?

Not sure what I was thinking there, that's not how globals work. Could we instead just cascade down the config? Otherwise, I'm not sure how else we can get the config into logger properly.

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

If we move config out of init.lua, to its own file, and update all the imports, this solves the issue, right?

The config module can be "export only" which should break any loops.

from nvim-ide.

distek avatar distek commented on June 30, 2024

I think that will work. Do you want a PR for it?

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

Yup!

from nvim-ide.

distek avatar distek commented on June 30, 2024

@BeeverFeever Do you want to work on this? If not, I can go at it later today.

from nvim-ide.

distek avatar distek commented on June 30, 2024

Sounds good, just let me know.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Ok will do.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Quick question, with the panel_groups in the config, do you think they should just be set in the setup function in init.lua before mergeing the users config? Otherwise a require is needed in config.lua(the new file with the default config)

from nvim-ide.

distek avatar distek commented on June 30, 2024

I think doing the requires in the config.lua is fine? Maybe by doing something like:

local bufferlist      = require('ide.components.bufferlist').Name

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Ok I'll see if that might work.

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

Should work, the init.lua files in each component dir dont need to refer to config.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

It still doesn't work. The only way I can think of getting it to work is by hard coding the values in. So for example you just put the name of the components you want as a string rather than using a require.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

@ldelossa The problem is that the components are referring to logger though.

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

@BeeverFeever yes I see.

main...refactor-for-logger - Here is a base refactor, I think this is fine, we'll just expose a method in the logger which sets the log level, and not give it the full config.

Want to use this as base to work the rest of the PR out?

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Yeah sure, that looks pretty good.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

@ldelossa Just wondering, do you want to use the vim.log.levels. for the logger levels or could I go with something where we set a table of log levels, like:
(in logger.lua)

local log_levels = {
    ['debug'] = 1,
    ['error'] = 2,
    ['warning'] = 3,
    ['info'] = 4,
}

and then use those values to detect whether to log the message or not?

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

This is what I've got so far. BeeverFeever/nvim-ide@47225a6

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

The 'set_log_level' probably take either a string, or an integer. But the log_level variable should probably be an int, so you can determine if you should log with a '>' or '<' evaluation.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Ok sounds good. I will make those changes and tidy it up then make a pr if it looks good to you otherwise?

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Also one more thing sorry, how would I run the logger tests?

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

Your diff looks fine, maybe we add a function which checks the incoming log_level variable to see if its a string or int, and attempt to return an integer.

Then we can do one more pass which removes all the strings in favor of using vim.log.levels directly. If we feel thats better.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Yeah that sounds better than using strings. Just wanted to make sure, did you want it to only log the level that is set by Logger.log_level or did you want it to log the set level and anything 'higher' than it?

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

Log level and higher. So if you set for "debug" it should log debug and all higher levels.

Tests are best effort so far. You can add them if youd like.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Ok thanks, how would I run the tests?

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

We don't have automated tests at this point. Most of the time I run tests manually to confirm something works.

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

Ahh ok fair enough

from nvim-ide.

BeeverFeever avatar BeeverFeever commented on June 30, 2024

I have done a bit but I ran into a problem where it seemed like Logger.log_level was just being set to nil and I was getting an error saying attempt to compare number with nil. I have no clue why this is happening.

BeeverFeever/nvim-ide@020a211
I hate leaving this broken right now but I just don't have any more time right now to work on it. If someone else wants to look at it they can or I will pick it up again in a couple days to see if I can get it to work.

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

@distek did you want to take it from here? If not I will.

@BeeverFeever no worries - glad you got to take a stab at it.

from nvim-ide.

ldelossa avatar ldelossa commented on June 30, 2024

Still needs an over-all logging pass, to place info logs in more appropriate places, but the leveled logging stuff is done.

from nvim-ide.

Related Issues (20)

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.