In non-daemon mode, initial serf slogs are user-visiable.

This commit is contained in:
~siprel 2020-06-10 21:17:55 +00:00
parent c721baee7f
commit dabe38be0d
3 changed files with 14 additions and 12 deletions

View File

@ -18,7 +18,7 @@ Stubbed out:
Bugs:
- [ ] In non-daemon mode, serf slogs/stderr output that happens *before*
- [x] In non-daemon mode, serf slogs/stderr output that happens *before*
the terminal connects should still go to stderr.
- [x] Serf stderr should also be send (along with slogs) to all connected
terminals.

View File

@ -85,16 +85,13 @@ import Urbit.Vere.Pier
import Urbit.Vere.Eyre.Multi (multiEyre, MultiEyreApi, MultiEyreConf(..))
import Urbit.Vere.Pier.Types
import Urbit.Vere.Serf
import Urbit.King.App
import Control.Concurrent (myThreadId)
import Control.Exception (AsyncException(UserInterrupt))
import Control.Lens ((&))
import System.Process (system)
import Text.Show.Pretty (pPrint)
import Urbit.King.App (KingEnv, PierEnv, kingEnvKillSignal)
import Urbit.King.App (killKingActionL, onKillKingSigL)
import Urbit.King.App (killPierActionL)
import Urbit.King.App (runKingEnvLogFile, runKingEnvStderr, runPierEnv)
import Urbit.Noun.Conversions (cordToUW)
import Urbit.Noun.Time (Wen)
import Urbit.Vere.LockFile (lockFile)
@ -167,10 +164,15 @@ toNetworkConfig CLI.Opts {..} = NetworkConfig { .. }
_ncNoHttp = oNoHttp
_ncNoHttps = oNoHttps
logSlogs :: HasLogFunc e => RIO e (TVar (Text -> IO ()))
logSlogs = do
logStderr :: HasStderrLogFunc e => RIO LogFunc a -> RIO e a
logStderr action = do
logFunc <- view stderrLogFuncL
runRIO logFunc action
logSlogs :: HasStderrLogFunc e => RIO e (TVar (Text -> IO ()))
logSlogs = logStderr $ do
env <- ask
newTVarIO (runRIO env . logTrace . ("SLOG: " <>) . display)
newTVarIO (runRIO env . logOther "serf" . display . T.strip)
tryBootFromPill
:: Bool

View File

@ -35,6 +35,7 @@ import Urbit.Vere.Behn (behn')
import Urbit.Vere.Eyre.Multi (MultiEyreApi)
import Urbit.Vere.Serf (Serf)
import qualified Data.Text as T
import qualified System.Entropy as Ent
import qualified Urbit.EventLog.LMDB as Log
import qualified Urbit.King.API as King
@ -296,11 +297,10 @@ pier (serf, log) vSlog startedSig multi = do
logDebug "TERMSERV External terminal connected."
-- Slogs go to both stderr and to the terminal.
atomically $ do
oldSlog <- readTVar vSlog
writeTVar vSlog $ \txt -> do
env <- ask
atomically $ writeTVar vSlog $ \txt -> runRIO env $ do
atomically $ Term.trace muxed txt
oldSlog txt
logOther "serf" (display $ T.strip txt)
-- Our call above to set the logging function which echos errors from the
-- Serf doesn't have the appended \r\n because those \r\n s are added in