aardvark-platform / aardvark.base

Aardvark.Base is the foundation of the open-source Aardvark Platform for visual computing, real-time graphics, and visualization.
https://aardvarkians.com/
Apache License 2.0
154 stars 9 forks source link

Directory.Exists check of log file #75

Closed luithefirst closed 2 years ago

luithefirst commented 2 years ago

We just ran into an issue where it turned out that the custom log directory that we set using Report.LogFileName does not exist. In this case, you get a really strange exception:

 Error: Could not create writer (many instances running?)
 Stacktrace:
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.CreateLogFileWriter(String fileName, Int32 cnt)
   at Aardvark.Base.Report.<>c.<.cctor>b__13_1(Int32 firstThreadIndex, LogType firstType, Int32 firstLevel, String firstMessage)
   at Aardvark.Base.TextLogTarget.Log(LogMsg msg)
   at Aardvark.Base.TextLogTarget.Log(Int32 threadIndex, LogMsg msg)
   at Aardvark.Base.MultiLogTarget.Log(Int32 threadIndex, LogMsg msg)
   at Aardvark.Base.JobReporter.Line(LogType type, Int32 level, ILogTarget target, String t0, Int32 p1, String t1)
   at Aardvark.Base.Report.Line(String line, Object[] args)
   at ZG.Hilite.Plugin.util.PluginLogger.Info(String pMsg, Object pComponent) in C:\- Work\pCon.Hilite.Sports\src\ZG.Hilite.Plugin\util\PluginLogger.cs:line 68

I now checked this in other applications and there "of course" have Directory.Exists checks. However, I think it would be much more convenient if this happens behind the scene, otherwise, we should make sure the error message is more helpful. Please have a look at this :-)