mirror of
https://github.com/4sval/FModel.git
synced 2026-12-05 15:56:04 -06:00
Open log
This commit is contained in:
Submodule CUE4Parse updated: 7f3a0ccf12...c95dd9b587
@@ -27,6 +27,8 @@ namespace FModel;
|
||||
/// </summary>
|
||||
public partial class App
|
||||
{
|
||||
public string LogFilePath { get; private set; }
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
@@ -115,7 +117,7 @@ public partial class App
|
||||
CacheManager.EnsureDirectories();
|
||||
|
||||
#if DEBUG
|
||||
var filePath = Path.Combine(UserSettings.Default.LogsDirectory, $"FModel-Debug-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
LogFilePath = Path.Combine(UserSettings.Default.LogsDirectory, $"FModel-Debug-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
|
||||
var viewerContexts = typeof(Snooper.Hosting.Bridge).Assembly.GetTypes()
|
||||
.Concat(typeof(EditorWindow).Assembly.GetTypes())
|
||||
@@ -123,7 +125,7 @@ public partial class App
|
||||
.Append("Snooper")
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
#else
|
||||
var filePath = Path.Combine(UserSettings.Default.LogsDirectory, $"FModel-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
LogFilePath = Path.Combine(UserSettings.Default.LogsDirectory, $"FModel-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
#endif
|
||||
const string template1 = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}";
|
||||
const string template2 = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{ClassName}] {ObjectPath}: {Message:lj}{NewLine}{Exception}";
|
||||
@@ -143,11 +145,11 @@ public partial class App
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByExcluding(IsConversionLibrary)
|
||||
.WriteTo.Console(outputTemplate: template1, theme: AnsiConsoleTheme.Literate)
|
||||
.WriteTo.File(outputTemplate: template1, path: filePath, shared: true))
|
||||
.WriteTo.File(outputTemplate: template1, path: LogFilePath, shared: true))
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByIncludingOnly(IsConversionLibrary)
|
||||
.WriteTo.Console(outputTemplate: template2, theme: AnsiConsoleTheme.Literate)
|
||||
.WriteTo.File(outputTemplate: template2, path: filePath, shared: true))
|
||||
.WriteTo.File(outputTemplate: template2, path: LogFilePath, shared: true))
|
||||
.MinimumLevel.Override("CUE4Parse_Conversion", LogEventLevel.Verbose)
|
||||
.WriteTo.Sink(ImGuiSink.Instance)
|
||||
.CreateLogger();
|
||||
|
||||
@@ -692,6 +692,24 @@
|
||||
|
||||
<controls:CustomRichTextBox Grid.Column="0" Grid.ColumnSpan="3" x:Name="LogRtbName" Style="{StaticResource CustomRichTextBox}" />
|
||||
<StackPanel Grid.Column="2" Orientation="Vertical" VerticalAlignment="Bottom" Margin="-5 -5 5 5">
|
||||
<Button Style="{DynamicResource {x:Static adonisUi:Styles.ToolbarButton}}"
|
||||
ToolTip="Open Log"
|
||||
Padding="0,4,0,4"
|
||||
Command="{Binding MenuCommand}"
|
||||
CommandParameter="ToolBox_Open_Log"
|
||||
Focusable="False">
|
||||
<Viewbox Width="16"
|
||||
Height="16"
|
||||
HorizontalAlignment="Center">
|
||||
<Canvas Width="24"
|
||||
Height="24">
|
||||
<Path StrokeThickness="2"
|
||||
Stroke="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}"
|
||||
StrokeLineJoin="Round"
|
||||
Data="M5 3h9l5 5v13H5z M14 3v5h5 M8 12h8 M8 16h8" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Style="{DynamicResource {x:Static adonisUi:Styles.ToolbarButton}}" ToolTip="Open Output Folder" Padding="0,4,0,4"
|
||||
Command="{Binding MenuCommand}" CommandParameter="ToolBox_Open_Output_Directory" Focusable="False">
|
||||
<Viewbox Width="16" Height="16" HorizontalAlignment="Center">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using AdonisUI.Controls;
|
||||
using FModel.Extensions;
|
||||
using FModel.Framework;
|
||||
@@ -68,6 +69,10 @@ public class MenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
case "ToolBox_Clear_Logs":
|
||||
FLogger.ClearLogs();
|
||||
break;
|
||||
case "ToolBox_Open_Log":
|
||||
if (App.Current is App app && File.Exists(app.LogFilePath))
|
||||
Process.Start(new ProcessStartInfo { FileName = app.LogFilePath, UseShellExecute = true });
|
||||
break;
|
||||
case "ToolBox_Open_Output_Directory":
|
||||
Process.Start(new ProcessStartInfo { FileName = UserSettings.Default.OutputDirectory, UseShellExecute = true });
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user