Skip to content

Commit

Permalink
new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Jan 21, 2024
1 parent 95373e3 commit 4f86808
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using System;
// this is not tested not working this is just random code at work will sort it when home - linka
using System.Threading;
using System.Threading.Tasks;

namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Utility
{
public enum LogSeverity
Expand All @@ -12,33 +14,39 @@ public enum LogSeverity
Warning,
Error
}

[NodeCategory("Obsidian/Utility/WriteToLog")]
public class WriteToLogNode : ValueFunctionNode<ExecutionContext, string>
public class WriteToLogNode : AsyncActionNode<ExecutionContext>
{
public readonly ValueInput<string> Value;
public readonly ValueInput<LogSeverity> Severity;
public readonly ValueInput<string> Tag;
public readonly ValueInput<User> HandlingUser;

public void Write()
public AsyncCall OnWriteStart;
public Continuation OnWriteComplete;

protected override async Task<IOperation> RunAsync(ExecutionContext context)
{
User user = HandlingUser.Evaluate(base.LocalUser);
User user = HandlingUser.Evaluate(context, context.LocalUser);
if (user != null)
{
switch (Severity.Evaluate())
await OnWriteStart.ExecuteAsync(context);
switch (Severity.Evaluate(context))
{
case LogSeverity.Log:
UniLog.Log(Tag.EvaluateRaw() + Value.EvaluateRaw()?.ToString());
UniLog.Log(Tag.EvaluateRaw(context) + Value.EvaluateRaw(context)?.ToString());
break;
case LogSeverity.Warning:
UniLog.Warning(Tag.EvaluateRaw() + Value.EvaluateRaw()?.ToString());
UniLog.Warning(Tag.EvaluateRaw(context) + Value.EvaluateRaw(context)?.ToString());
break;
case LogSeverity.Error:
UniLog.Error(Tag.EvaluateRaw() + Value.EvaluateRaw()?.ToString());
UniLog.Error(Tag.EvaluateRaw(context) + Value.EvaluateRaw(context)?.ToString());
break;
}
return OnWriteComplete.Target;
}
return null;
}
}
}
}

0 comments on commit 4f86808

Please sign in to comment.