-
-
Notifications
You must be signed in to change notification settings - Fork 392
Improve logging #2558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Improve logging #2558
Changes from 14 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
671211e
convert to contravariant logging style part 1, uses additional hardco…
eddiemundo acc1ef4
Merge branch 'master' of https://github.com/haskell/haskell-language-…
eddiemundo bb2c6a2
convert Session to contravariant logging style
eddiemundo 235b87d
convert Plugin/HLS and FireStore to contravariant logging style
eddiemundo b4ebdd7
convert Rules (and most of the universe) to contravariant logging style
eddiemundo c0190d7
fix tests, allow old style logging and contravariant logging to write…
eddiemundo 9946830
fix import inside wrong CPP
eddiemundo 20a3761
add CPP for LogTactic constructor
eddiemundo 528439c
remove redundant import
eddiemundo e69839d
fix ghcide tests
eddiemundo e6b4bd7
remove unused import
eddiemundo fb5033a
fix plugin tests
eddiemundo 4cfa737
LSP_TEST_STDERR should apply to contra logger as well
eddiemundo c874657
fix tactic plugin test
eddiemundo 2b3b3b3
use CPP for Log datatype plugin constructors, remove unused imports
eddiemundo 23a57c2
add a few Pretty instances, add prettyprinter to haskell-language-sev…
eddiemundo 504a3df
add Pretty Log instances for Session, FileStore, Notifications
eddiemundo 17937d2
add remaining Pretty Log instances
eddiemundo a2fe371
add logToPriorities
eddiemundo 5d879b0
fix slight interleaving issue with hslogger and logger both logging, …
eddiemundo 9178f1c
Merge branch 'master' of https://github.com/haskell/haskell-language-…
eddiemundo e94fd03
forgot to add .cabal files with hslogger dep
eddiemundo eb7a69a
dont use UnliftIO file IO helpers because they are too new
eddiemundo d430883
remove log helper comments, use Doc instead of Text as final console/…
eddiemundo 14a126c
remove accidentally added useless file, removed prettyprinter dep fro…
eddiemundo 37ddc54
Merge branch 'master' of https://github.com/haskell/haskell-language-…
eddiemundo e7f8320
use deprecated prettyprint modules import for the sake of circleci gh…
eddiemundo 0ced860
fix conflicts
eddiemundo 23c2ad9
use dummy stderr logger for plugin cli commands, use priorityToHsLogg…
eddiemundo 72b441e
remove old plugin detritus that somehow got committed
eddiemundo 198e0ba
fix prettyprinter imports for 8.6.5
eddiemundo 74e9c0e
try enforcing prettyprinter bounds?
eddiemundo 5f045ed
enforcing bound makes no sense
eddiemundo a6d0ad1
fix merge conflict
eddiemundo 2a9f686
maybe changing stack yamls does trick
eddiemundo 42c22e5
filter out warnings when their diags are empty to more closely match …
eddiemundo d13eb23
Merge branch 'master' of https://github.com/haskell/haskell-language-…
eddiemundo 1978a52
add ability to select wanted logging columns, match prev ghcide exe l…
eddiemundo 24aa5f6
dont log anything when diags are empty in some defineEarlyCutoff vers…
eddiemundo 483b565
use non-deprecated prettyprinter imports
eddiemundo c2d3d01
fix ghcide test module
eddiemundo 8355111
change logWith to accept priority at call site, remove all logToPrior…
eddiemundo 35e0652
fix conflicts
eddiemundo 6666995
remove useless hiding import list, add comments to default recorder m…
eddiemundo 52c5a55
make cradleToOptsAndLibDir take concrete cradle to remove existential…
eddiemundo cc7dd2b
Types.Logger now re-exports prettyprinter, remove unused dependencies…
eddiemundo 88ae7e2
existential type var to remove boilerplate in Plugins.hs, remove a fe…
eddiemundo 1fd42ae
add SourceLoc logging column, inline logToDoc functions, add comment …
eddiemundo 5bb4fcf
fix conflicts
eddiemundo c1f1f3d
qualify a name to match original source
eddiemundo 3d71348
fix -WError
eddiemundo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,50 @@ | ||
-- Copyright (c) 2019 The DAML Authors. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
module Main(main) where | ||
|
||
import Ide.Arguments (Arguments (..), GhcideArguments (..), | ||
getArguments) | ||
import Ide.Main (defaultMain) | ||
import Plugins | ||
import Data.Function ((&)) | ||
import Data.Text (Text) | ||
import qualified Data.Text as Text | ||
import Development.IDE.Types.Logger (Priority (Debug, Info), | ||
WithPriority (WithPriority, priority), | ||
cfilter, cmap, setupHsLogger, | ||
withDefaultTextWithPriorityRecorderAndHandle) | ||
import Ide.Arguments (Arguments (..), | ||
GhcideArguments (..), | ||
getArguments) | ||
import Ide.Main (defaultMain) | ||
import qualified Ide.Main as IdeMain | ||
import qualified Plugins | ||
import qualified System.Log as HsLogger | ||
|
||
data Log | ||
= LogIdeMain IdeMain.Log | ||
| LogPlugins Plugins.Log | ||
deriving Show | ||
|
||
logToTextWithPriority :: Log -> WithPriority Text | ||
logToTextWithPriority = WithPriority Info . Text.pack . show | ||
|
||
main :: IO () | ||
main = do | ||
args <- getArguments "haskell-language-server" (idePlugins False) | ||
args <- getArguments "haskell-language-server" (Plugins.idePlugins undefined False) | ||
|
||
let (hsLoggerMinLogLevel, minPriority, logFilePath, includeExamplePlugins) = | ||
case args of | ||
Ghcide GhcideArguments{ argsTesting, argsDebugOn, argsLogFile, argsExamplePlugin } -> | ||
let (minHsLoggerLogLevel, minPriority) = | ||
if argsDebugOn || argsTesting then (HsLogger.DEBUG, Debug) else (HsLogger.INFO, Info) | ||
in (minHsLoggerLogLevel, minPriority, argsLogFile, argsExamplePlugin) | ||
_ -> (HsLogger.INFO, Info, Nothing, False) | ||
|
||
let withExamples = | ||
case args of | ||
Ghcide GhcideArguments{..} -> argsExamplePlugin | ||
_ -> False | ||
withDefaultTextWithPriorityRecorderAndHandle logFilePath $ \textWithPriorityRecorder handle -> do | ||
-- until the contravariant logging system is fully in place | ||
setupHsLogger (Just handle) ["hls", "hie-bios"] hsLoggerMinLogLevel | ||
let recorder = | ||
textWithPriorityRecorder | ||
& cfilter (\WithPriority{ priority } -> priority >= minPriority) | ||
& cmap logToTextWithPriority | ||
|
||
defaultMain args (idePlugins withExamples) | ||
defaultMain (cmap LogIdeMain recorder) args (Plugins.idePlugins (cmap LogPlugins recorder) includeExamplePlugins) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.