Skip to content

Commit

Permalink
update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
DedSec256 committed May 3, 2021
1 parent fada15b commit 9d8eb37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,29 @@
using JetBrains.Diagnostics;
using JetBrains.Lifetimes;
using JetBrains.Platform.RdFramework.ExternalProcess;
using JetBrains.Platform.RdFramework.ExternalProcess.Util;
using JetBrains.Rd.Impl;
using JetBrains.Rider.FSharp.ExternalFormatter.Client;
using JetBrains.Util;
using JetBrains.Util.Logging;
using JetBrains.Rd.Tasks;

namespace FSharp.ExternalFormatter.Host
{
internal class ExternalFormatterEndPoint : ProtocolEndPoint<RdFSharpExternalFormatterModel, RdSimpleDispatcher>
{
private readonly ExternalCodeFormatter myCodeFormatter;
private readonly FantomasCodeFormatter myCodeFormatter;
protected override string ProtocolName => "External Formatter Host";

public ExternalFormatterEndPoint() : base(FantomasProtocolConstants.PARENT_PROCESS_PID_ENV_VARIABLE)
{
myCodeFormatter = new ExternalCodeFormatter();
myCodeFormatter = new FantomasCodeFormatter();
}

protected override RdSimpleDispatcher InitDispatcher(Lifetime lifetime, ILogger logger) =>
new RdSimpleDispatcher(lifetime, logger);

protected override void InitLogger(Lifetime lifetime, string path)
{
LogManager.Instance.SetConfig(new XmlLogConfigModel());
var logPath = FileSystemPath.TryParse(path);
if (logPath.IsNullOrEmpty()) return;

var logEventListener = new FileLogEventListener(logPath);
LogManager.Instance.AddOmnipresentLogger(lifetime, logEventListener, LoggingLevel.TRACE);
}
protected override void InitLogger(Lifetime lifetime, string path) =>
ProtocolEndPointUtil.InitLogger(path, lifetime, LoggingLevel.TRACE);

protected override RdFSharpExternalFormatterModel InitModel(Lifetime lifetime, JetBrains.Rd.Impl.Protocol protocol)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace FSharp.ExternalFormatter.Host
{
internal class ExternalCodeFormatter
internal class FantomasCodeFormatter
{
private readonly FSharpChecker myChecker =
FSharpChecker.Create(null, null, null, null, null, null, null, null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using JetBrains.Diagnostics;
using JetBrains.Lifetimes;
using JetBrains.Platform.RdFramework.ExternalProcess;
using JetBrains.Platform.RdFramework.ExternalProcess.Util;
using JetBrains.Rd.Impl;
using JetBrains.ReSharper.Plugins.FSharp.TypeProviders.Host.Hosts;
using JetBrains.ReSharper.Plugins.FSharp.TypeProviders.Protocol;
using JetBrains.Rider.FSharp.TypeProviders.Protocol.Server;
using JetBrains.Util;
using JetBrains.Util.Logging;

namespace JetBrains.ReSharper.Plugins.FSharp.TypeProviders.Host
{
Expand All @@ -30,12 +30,7 @@ protected override RdSimpleDispatcher InitDispatcher(Lifetime lifetime, ILogger

protected override void InitLogger(Lifetime lifetime, string path)
{
LogManager.Instance.SetConfig(new XmlLogConfigModel());
var logPath = FileSystemPath.TryParse(path);
if (logPath.IsNullOrEmpty()) return;

var logEventListener = new FileLogEventListener(logPath);
LogManager.Instance.AddOmnipresentLogger(lifetime, logEventListener, LoggingLevel.TRACE);
ProtocolEndPointUtil.InitLogger(path, lifetime, LoggingLevel.TRACE);
Logger.Log(LoggingLevel.INFO, $"Process Runtime: {RuntimeInformation.FrameworkDescription}");
}

Expand Down

0 comments on commit 9d8eb37

Please sign in to comment.