Development Merge 2025.10.18 #4
@@ -7,18 +7,23 @@ public class FileLogger : LoggerBase
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public readonly string FilePath;
 | 
					    public readonly string FilePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public FileLogger(string filePath)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        FilePath = filePath;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (Path.GetDirectoryName(filePath) is string directoryPath)
 | 
					 | 
				
			||||||
            Directory.CreateDirectory(directoryPath);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        File.Open(filePath, FileMode.Create).Close();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void Write(string message)
 | 
					    protected override void Write(string message)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        File.AppendAllTextAsync(FilePath, $"{message}{Environment.NewLine}");
 | 
					        File.AppendAllTextAsync(FilePath, $"{message}{Environment.NewLine}");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FileLogger(string filePath)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        FilePath = filePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool isRelativePath = Path.GetFullPath(filePath).CompareTo(filePath) != 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (isRelativePath)
 | 
				
			||||||
 | 
					            FilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (Path.GetDirectoryName(FilePath) is string directoryPath)
 | 
				
			||||||
 | 
					            Directory.CreateDirectory(directoryPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        File.Open(FilePath, FileMode.Create).Close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user