mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
got tracing and loggin working in opentelemetry
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using LocalModels;
|
||||
using Management.Services;
|
||||
using YamlDotNet.Serialization;
|
||||
@@ -7,21 +8,24 @@ public class FileStorageManager
|
||||
private readonly MyLogger<FileStorageManager> logger;
|
||||
private readonly CourseMarkdownLoader _courseMarkdownLoader;
|
||||
private readonly MarkdownCourseSaver _saveMarkdownCourse;
|
||||
private readonly ILogger<FileStorageManager> _otherLogger;
|
||||
private readonly string _basePath;
|
||||
|
||||
public FileStorageManager(
|
||||
MyLogger<FileStorageManager> logger,
|
||||
CourseMarkdownLoader courseMarkdownLoader,
|
||||
MarkdownCourseSaver saveMarkdownCourse
|
||||
MarkdownCourseSaver saveMarkdownCourse,
|
||||
ILogger<FileStorageManager> otherLogger
|
||||
)
|
||||
{
|
||||
using var activity = DiagnosticsConfig.Source.StartActivity("loading storage directory");
|
||||
this.logger = logger;
|
||||
_courseMarkdownLoader = courseMarkdownLoader;
|
||||
_saveMarkdownCourse = saveMarkdownCourse;
|
||||
_otherLogger = otherLogger;
|
||||
_basePath = FileConfiguration.GetBasePath();
|
||||
|
||||
this.logger.Log("Using storage directory: " + _basePath);
|
||||
|
||||
}
|
||||
public async Task SaveCourseAsync(LocalCourse course, LocalCourse? previouslyStoredCourse)
|
||||
{
|
||||
@@ -36,6 +40,7 @@ public class FileStorageManager
|
||||
|
||||
public async Task<IEnumerable<LocalCourse>> LoadSavedMarkdownCourses()
|
||||
{
|
||||
|
||||
return await _courseMarkdownLoader.LoadSavedMarkdownCourses();
|
||||
}
|
||||
|
||||
@@ -43,11 +48,18 @@ public class FileStorageManager
|
||||
{
|
||||
if(!Directory.Exists(_basePath))
|
||||
throw new DirectoryNotFoundException($"Cannot get empty directories, {_basePath} does not exist");
|
||||
|
||||
|
||||
return Directory
|
||||
.GetDirectories(_basePath, "*")
|
||||
.Where(dir => !Directory.EnumerateFileSystemEntries(dir).Any())
|
||||
.ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DiagnosticsConfig
|
||||
{
|
||||
public const string SourceName = "canvas-management-source";
|
||||
public static ActivitySource Source = new ActivitySource(SourceName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user