From 28d5f0cf220a1b7162eaa1535e72e6cad2362ee4 Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Fri, 26 Oct 2018 13:49:07 +0200 Subject: [PATCH] use bytestring for multithreaded stderr output --- hslogger.cabal | 4 ++-- src/System/Log/Handler/Syslog.hs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hslogger.cabal b/hslogger.cabal index 42ae206..fdfd6bf 100644 --- a/hslogger.cabal +++ b/hslogger.cabal @@ -49,8 +49,8 @@ Library if !os(windows) Build-Depends: unix if flag(small_base) - build-depends: base >= 4 && < 5, containers, directory, process, - time, old-locale + build-depends: base >= 4 && < 5, bytestring, containers, directory, + process, time, old-locale else build-depends: base < 3, time -- GHC-Options: -O2 diff --git a/src/System/Log/Handler/Syslog.hs b/src/System/Log/Handler/Syslog.hs index 7b0d5f9..5603c35 100644 --- a/src/System/Log/Handler/Syslog.hs +++ b/src/System/Log/Handler/Syslog.hs @@ -44,6 +44,7 @@ module System.Log.Handler.Syslog( ) where import qualified Control.Exception as E +import qualified Data.ByteString.Char8 as BC import System.Log import System.Log.Formatter import System.Log.Handler @@ -249,7 +250,7 @@ instance LogHandler SyslogHandler where setFormatter sh f = sh{formatter = f} getFormatter sh = formatter sh emit sh (prio, msg) _ = do - when (elem PERROR (options sh)) (hPutStrLn stderr msg) + when (elem PERROR (options sh)) (BC.hPutStrLn stderr $ BC.pack msg) pidPart <- getPidPart void $ sendstr (toSyslogFormat msg pidPart) where