-
Notifications
You must be signed in to change notification settings - Fork 31
Conversation
This is very nice, although, scry have some very verbose logs like this:
So, I suggest to review them and remove the extreme verbosity: Otherwise the lsp-client/editor would freeze because too many logs 😅 sometimes scry generate MB of debug data: |
@faustinoaq Yes I noticed that as well. I can remove some of the more "verbose" logging if that is desirable or we could log that stuff a tempfile like we were doing (i.e. have two loggers, a scry logger and a client logger), but that might get confusing. I am not sure how useful some of these really big logs statements are 🤔 |
@bmulvihill Yeah, that may be confusing. I think we should cleanup logging and just keep client logger. |
@@ -57,7 +57,6 @@ module Scry | |||
|
|||
def get_file(text_document : TextDocumentIdentifier) | |||
filename = TextDocument.uri_to_filename(text_document.uri) | |||
Log.logger.debug("@open_files: #{@open_files}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this one was the most verbose 👍
Hey @bmulvihill I already tested this and is very useful and works very nice @crystal-lang-tools/scry Maybe we can add a log spec on a new PR, WDYT? 😅 |
@faustinoaq sorry I got sidetracked on that file bug last week when working on specs. I’ll try to wrap this up tomorrow |
c56878f
to
89c4d6b
Compare
@crystal-lang-tools/scry @faustinoaq I removed some of the log calls, and added some specs. I am still not 100% happy w. this, but I am short on time lately. I would appreciate any feedback |
src/scry/log.cr
Outdated
logger = Logger.new(log_file) | ||
logger.level = Logger::INFO | ||
logger | ||
logger = ClientLogger.new(Client.instance.io) | ||
end | ||
|
||
@@logger : Logger = initialize_logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a method anymore, you can directly use ClientLogger.new ...
src/scry/log.cr
Outdated
logger = Logger.new(log_file) | ||
logger.level = Logger::INFO | ||
logger | ||
logger = ClientLogger.new(Client.instance.io) | ||
end | ||
|
||
@@logger : Logger = initialize_logger | ||
|
||
def self.logger | ||
@@logger | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: class_getter logger
does the same thing ;)
(or even class_property
now that you also have a setter below)
@@ -0,0 +1,8 @@ | |||
module Scry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be Scry::Protocol
?
I just realized that (all?) the LSP protocol is not in a Protocol
module, as I think it should, to properly see on usage when you're using a protocol type or not (that's important!).
This can be done later in another PR though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm already working on that 👍
src/scry/client.cr
Outdated
class Client | ||
alias ClientMessage = Initialize | ResponseMessage | NotificationMessage | Nil | ||
|
||
def self.instance(io : IO = STDOUT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bit tricky if you want to use your own IO (i.e: in specs), you need to make sure that the first call to Client.instance
has an IO, and you can't change the IO later once it's set.
I think it would be better to keep the Client.instance
as a simple getter, and change the architecture: maybe Client
doesn't even need to be a singleton?
As I said in one of the comment, I think Here is a way to do it:
This way you never have to use a Do you see what I mean? |
I am also wondering if there is any use for the |
src/scry/log.cr
Outdated
@closed = false | ||
@mutex = Mutex.new | ||
@io = @client.io | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you copy this constructor from Logger?
I would suggest to keep it simple, and use super
to call the Logger's normal constructor.
E.g:
def initialize(@client : Client, level = Severity::INFO)
super(@client.io, level)
end
I don't think we need the rest for now.
But as you like :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes, good call ;)
Hmm yeah |
@bmulvihill Hi, I just tried latest changes and this feature still works fine 🎉 Although, I notices a new BTW, Do you know what happened with the Edit: With "
I think we used to log this as well. Currently I can't see it on scry log 😅 |
@crystal-lang-tools/scry Made some adjustments, null should no longer be logged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 😃
@bmulvihill note for later: next time can you make individual commits for new changes? For example you removed the null
, by not making a commit for that change only, I have no idea what you did to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR will change the logging to log to the LSP client instead of to the
scry.out
tempfile.I am opening the PR for discussion/ideas. I still have to write specs and such.
Currently the PR does the following
LogMessageParams
andMessageType
to the protocolMessageType
toProtocolMessage
Client
which can be used to send messages to the LSP client