forked from haskell/haskell-language-server
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* convert to contravariant logging style part 1, uses additional hardcoded log file to see it side by side with original logging * convert Session to contravariant logging style * convert Plugin/HLS and FireStore to contravariant logging style * convert Rules (and most of the universe) to contravariant logging style * fix tests, allow old style logging and contravariant logging to write to same log file * fix import inside wrong CPP * add CPP for LogTactic constructor * remove redundant import * fix ghcide tests * remove unused import * fix plugin tests * LSP_TEST_STDERR should apply to contra logger as well * fix tactic plugin test * use CPP for Log datatype plugin constructors, remove unused imports * add a few Pretty instances, add prettyprinter to haskell-language-sever and hls-plugin-api dependencies * add Pretty Log instances for Session, FileStore, Notifications * add remaining Pretty Log instances * add logToPriorities * fix slight interleaving issue with hslogger and logger both logging, have default logger be mutex stderr or file handle, use stderr if failing to open log file * forgot to add .cabal files with hslogger dep * dont use UnliftIO file IO helpers because they are too new * remove log helper comments, use Doc instead of Text as final console/file logger input, renaming, export Log constructors * remove accidentally added useless file, removed prettyprinter dep from hls-plugin-api because stack ghc8.6.5 doesnt have it? * use deprecated prettyprint modules import for the sake of circleci ghc-8.6.5 * use dummy stderr logger for plugin cli commands, use priorityToHsLoggerPriority function instead of manual mapping * remove old plugin detritus that somehow got committed * fix prettyprinter imports for 8.6.5 * try enforcing prettyprinter bounds? * enforcing bound makes no sense * maybe changing stack yamls does trick * filter out warnings when their diags are empty to more closely match original * add ability to select wanted logging columns, match prev ghcide exe logging behaviour * dont log anything when diags are empty in some defineEarlyCutoff versions * use non-deprecated prettyprinter imports * fix ghcide test module * change logWith to accept priority at call site, remove all logToPriority functions, add cmapWithPrio that contramaps through WithPriority * remove useless hiding import list, add comments to default recorder makers * make cradleToOptsAndLibDir take concrete cradle to remove existential type var in Log constructor * Types.Logger now re-exports prettyprinter, remove unused dependencies on prettyprinter and hslogger * existential type var to remove boilerplate in Plugins.hs, remove a few Show instances * add SourceLoc logging column, inline logToDoc functions, add comment explaining hslogger setup existence * qualify a name to match original source * fix -WError
- Loading branch information
1 parent
2e8c95b
commit 30750a7
Showing
46 changed files
with
1,572 additions
and
645 deletions.
There are no files selected for viewing
This file contains 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 Development.IDE.Types.Logger (Priority (Debug, Info), | ||
WithPriority (WithPriority, priority), | ||
cfilter, cmapWithPrio, | ||
makeDefaultStderrRecorder, | ||
withDefaultRecorder) | ||
import Ide.Arguments (Arguments (..), | ||
GhcideArguments (..), | ||
getArguments) | ||
import Ide.Main (defaultMain) | ||
import qualified Ide.Main as IdeMain | ||
import qualified Plugins | ||
import Prettyprinter (Pretty (pretty)) | ||
|
||
data Log | ||
= LogIdeMain IdeMain.Log | ||
| LogPlugins Plugins.Log | ||
|
||
instance Pretty Log where | ||
pretty log = case log of | ||
LogIdeMain ideMainLog -> pretty ideMainLog | ||
LogPlugins pluginsLog -> pretty pluginsLog | ||
|
||
main :: IO () | ||
main = do | ||
args <- getArguments "haskell-language-server" (idePlugins False) | ||
-- plugin cli commands use stderr logger for now unless we change the args | ||
-- parser to get logging arguments first or do more complicated things | ||
pluginCliRecorder <- cmapWithPrio pretty <$> makeDefaultStderrRecorder Nothing Info | ||
args <- getArguments "haskell-language-server" (Plugins.idePlugins (cmapWithPrio LogPlugins pluginCliRecorder) False) | ||
|
||
let (minPriority, logFilePath, includeExamplePlugins) = | ||
case args of | ||
Ghcide GhcideArguments{ argsTesting, argsDebugOn, argsLogFile, argsExamplePlugin } -> | ||
let minPriority = if argsDebugOn || argsTesting then Debug else Info | ||
in (minPriority, argsLogFile, argsExamplePlugin) | ||
_ -> (Info, Nothing, False) | ||
|
||
let withExamples = | ||
case args of | ||
Ghcide GhcideArguments{..} -> argsExamplePlugin | ||
_ -> False | ||
withDefaultRecorder logFilePath Nothing minPriority $ \textWithPriorityRecorder -> do | ||
let recorder = | ||
textWithPriorityRecorder | ||
& cfilter (\WithPriority{ priority } -> priority >= minPriority) | ||
& cmapWithPrio pretty | ||
|
||
defaultMain args (idePlugins withExamples) | ||
defaultMain (cmapWithPrio LogIdeMain recorder) args (Plugins.idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins) |
This file contains 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 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.