Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
$DEBUG->ThemeCheck.debug?
Browse files Browse the repository at this point in the history
$DEBUG is a standard ruby flag. It also logs all exceptions to STDERR.
When using the language server with this option, things were weird in
the logs pane. Since stuff kept getting logged even though the server
was closing and the exceptions were being caught.

This resulted in logs that stayed around instead of going away. Took me
way too long to figure that out. By moving to ThemeCheck.debug? instead,
this doesn't happen anymore.
  • Loading branch information
charlespwd committed Sep 27, 2021
1 parent 075a191 commit 8dcdfe7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 0 additions & 4 deletions exe/theme-check-language-server
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@

require 'theme_check'

if ENV["THEME_CHECK_DEBUG"] == "true"
$DEBUG = true
end

status_code = ThemeCheck::LanguageServer.start
exit! status_code
4 changes: 4 additions & 0 deletions lib/theme_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
Encoding.default_internal = Encoding::UTF_8

module ThemeCheck
def self.debug?
ENV["THEME_CHECK_DEBUG"] == "true"
end

def self.with_liquid_c_disabled
if defined?(Liquid::C)
was_enabled = Liquid::C.enabled
Expand Down
4 changes: 2 additions & 2 deletions lib/theme_check/language_server/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def log(message)
def read_message
message_body = @messenger.read_message
message_json = JSON.parse(message_body)
@messenger.log(JSON.pretty_generate(message_json)) if $DEBUG
@messenger.log(JSON.pretty_generate(message_json)) if ThemeCheck.debug?
message_json
end

def send_message(message_hash)
message_hash[:jsonrpc] = '2.0'
message_body = JSON.dump(message_hash)
@messenger.log(JSON.pretty_generate(message_hash)) if $DEBUG
@messenger.log(JSON.pretty_generate(message_hash)) if ThemeCheck.debug?
@messenger.send_message(message_body)
end

Expand Down

0 comments on commit 8dcdfe7

Please sign in to comment.