Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log.Note() - midway beween Log.Info() and Log.Warning() #1315

Closed
wants to merge 6 commits into from

Conversation

originalfoo
Copy link
Member

@originalfoo originalfoo commented Jan 25, 2022

  • Add new LogLevel.Note enum (sits between Info and Warning)
  • Add Log.Note() and Log.NoteFormat()
  • Add Log.MiniStackTrace() helper method to do stacktrace chopping
    • Trims trim lines from start (default 2)
    • Truncates remining list to trunc lines (default 3)
    • Prepends a prepend string, unless it's null or ""

It's useful when you want a bit of stack trace but don't want users complaining something is broken.

Example: Go from this Log.Warning(str):

Warning 720.3672530: Translated file RoadUI.sign_stop_en-gb.png not found!
   at CSUtil.Commons.Log.LogToFile(System.String log, LogLevel level)
   at CSUtil.Commons.Log.Warning(System.String s)
   at TrafficManager.UI.Translation.GetTranslatedFileName(System.String filename, System.String language)
   at TrafficManager.UI.Translation.GetTranslatedFileName(System.String filename)
   at TrafficManager.UI.Textures.RoadUI.OnLevelLoading()
   at TrafficManager.Lifecycle.TMPELifecycle.Load()
   at TrafficManager.Lifecycle.TrafficManagerMod.OnLevelLoaded(LoadMode mode)
   at LoadingWrapper.LoadingWrapper.OnLevelLoaded_Patch4(.LoadingWrapper , UpdateMode )
   at LoadingManager+<LoadLevelComplete>c__Iterator9.MoveNext()
   at LoadingManager.FpsBoosterUpdate()
   at BehaviourUpdater.Updater.Update()

To this Log.Note(str):

Note 720.3672530: Translated file RoadUI.sign_stop_en-gb.png not found!
-   at CSUtil.Commons.Log.LogToFile(System.String log, LogLevel level)
-   at CSUtil.Commons.Log.Warning(System.String s)
   at TrafficManager.UI.Translation.GetTranslatedFileName(System.String filename, System.String language)
   at TrafficManager.UI.Translation.GetTranslatedFileName(System.String filename)
   at TrafficManager.UI.Textures.RoadUI.OnLevelLoading()
-   at TrafficManager.Lifecycle.TMPELifecycle.Load()
-   at TrafficManager.Lifecycle.TrafficManagerMod.OnLevelLoaded(LoadMode mode)
-   at LoadingWrapper.LoadingWrapper.OnLevelLoaded_Patch4(.LoadingWrapper , UpdateMode )
-   at LoadingManager+<LoadLevelComplete>c__Iterator9.MoveNext()
-   at LoadingManager.FpsBoosterUpdate()
-   at BehaviourUpdater.Updater.Update()

Or this Log.Note(str, 4):

Note 720.3672530: Translated file RoadUI.sign_stop_en-gb.png not found!
-   at TrafficManager.UI.Translation.GetTranslatedFileName(System.String filename, System.String language)
-   at TrafficManager.UI.Translation.GetTranslatedFileName(System.String filename)
   at TrafficManager.UI.Textures.RoadUI.OnLevelLoading()
+   at TrafficManager.Lifecycle.TMPELifecycle.Load()
+   at TrafficManager.Lifecycle.TrafficManagerMod.OnLevelLoaded(LoadMode mode)

Or this `Log.Note(str, 4, 1):

Note 720.3672530: Translated file RoadUI.sign_stop_en-gb.png not found!
   at TrafficManager.UI.Textures.RoadUI.OnLevelLoading()
-   at TrafficManager.Lifecycle.TMPELifecycle.Load()
-   at TrafficManager.Lifecycle.TrafficManagerMod.OnLevelLoaded(LoadMode mode)

@originalfoo originalfoo added low priority Issue with low priority of work technical Tasks that need to be performed in order to improve quality and maintainability labels Jan 25, 2022
@originalfoo originalfoo added this to the 11.7.0 milestone Jan 25, 2022
@originalfoo originalfoo self-assigned this Jan 25, 2022
@originalfoo originalfoo changed the title Subtle warnings Log.Note() - midway beween Log.Info() and Log.Warning() Jan 25, 2022
@originalfoo originalfoo added the ⏸Paused Paused for now label Feb 2, 2022
@originalfoo originalfoo removed this from the 11.7.0 milestone Feb 2, 2022
@originalfoo originalfoo added this to the Not Applicable milestone Feb 3, 2022
@originalfoo
Copy link
Member Author

Made obsolete by #1348

@originalfoo originalfoo closed this Feb 3, 2022
@originalfoo originalfoo deleted the subtle-warnings branch February 3, 2022 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority Issue with low priority of work ⏸Paused Paused for now technical Tasks that need to be performed in order to improve quality and maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant