-
Notifications
You must be signed in to change notification settings - Fork 13
BHoM_Engine: Enhance the logging functionality by including ability to suppress logging if desired #3286
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
Merged
Merged
BHoM_Engine: Enhance the logging functionality by including ability to suppress logging if desired #3286
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
276affd
#1840 - ability to switch off and on recording specific events into t…
ae9290e
Tidy up usings
238d30e
Ability to throw errors for @alelom
49faab0
Add ability to retrive events recorded during a switch off mode
47eb170
Add ability to query events based on bookmarks
1cf4779
Rename from Switch Off/On to Suppress/Unsuppress
93f06c3
Rename RetriveSwitchedOffLog to RetriveSuppressedLog
befdb82
Change variable names to change the state and make the code more read…
57b7df7
Update exception throwing to use suppress terminology in line with su…
b9efd19
Spelling fix for Retrive -> Retrieve
5af7e08
Go to Start/Stop suppressing from @pawelbaran comment
ac987ba
Update documentation compliance
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved. | ||
* | ||
* Each contributor holds copyright over their respective contributions. | ||
* The project versioning (Git) records all such contribution source information. | ||
* | ||
* | ||
* The BHoM is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3.0 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The BHoM is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
*/ | ||
|
||
using BH.oM.Base.Debugging; | ||
using BH.oM.Base.Attributes; | ||
using System.Linq; | ||
using System.ComponentModel; | ||
using System; | ||
|
||
namespace BH.Engine.Base | ||
{ | ||
public static partial class Compute | ||
{ | ||
/***************************************************/ | ||
/**** Public Methods ****/ | ||
/***************************************************/ | ||
|
||
[Description("Retrive the events recorded while the logging system was switched off and put them into the main log. When the logging system is switched off, recording of events is done in quiet mode which means UIs are not made aware of the events and the main event log does not have knowledge of them. We still record the events though because they may be useful. This method will move any events stored within the log when it was switched off up to the main log for visibiliy and inspection, and will reset the quiet log to a clean state.")] | ||
[Output("True if no error occurs in moving up events recorded during a quiet period.")] | ||
public static bool RetriveSwitchedOffLog() | ||
{ | ||
lock(Global.DebugLogLock) | ||
{ | ||
Log switchedOffLog = Query.SwitchedOffDebugLog(); | ||
Log debugLog = Query.DebugLog(); | ||
|
||
debugLog.CurrentEvents.AddRange(switchedOffLog.CurrentEvents); | ||
debugLog.AllEvents.AddRange(switchedOffLog.AllEvents); | ||
|
||
Query.ResetSwitchedOffDebugLog(); //Now we've moved the switched off log events into the main log, we don't need the switched off log to also keep a copy of them | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved. | ||
* | ||
* Each contributor holds copyright over their respective contributions. | ||
* The project versioning (Git) records all such contribution source information. | ||
* | ||
* | ||
* The BHoM is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3.0 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The BHoM is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
*/ | ||
|
||
using BH.oM.Base.Debugging; | ||
using BH.oM.Base.Attributes; | ||
using System.Linq; | ||
using System.ComponentModel; | ||
using System; | ||
|
||
namespace BH.Engine.Base | ||
{ | ||
public static partial class Compute | ||
{ | ||
/***************************************************/ | ||
/**** Public Methods ****/ | ||
/***************************************************/ | ||
|
||
[Description("Switch off throwing errors when they reach the event log.")] | ||
public static void SwitchErrorThrowOff() | ||
{ | ||
m_ThrowError = false; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch on throwing errors by the event log. By default, errors are NOT thrown when they reach the BHoM event log. Switching this on will result in errors hitting the event log and being thrown, and if a suitable try/catch is not in place to catch this, you may encounter crashes in your system. Use at your own risk. Please consult the documentation for more information.")] //ToDo: Write the documentation on BHoM.xyz for this system | ||
[Input("areYouSure", "Set this to true if you are sure you want to throw all errors recorded by the event log for try/catch statements to handle.")] | ||
public static void SwitchErrorThrowOn(bool areYouSure) | ||
{ | ||
if (!areYouSure) | ||
return; | ||
|
||
m_ThrowError = true; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved. | ||
* | ||
* Each contributor holds copyright over their respective contributions. | ||
* The project versioning (Git) records all such contribution source information. | ||
* | ||
* | ||
* The BHoM is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3.0 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The BHoM is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
*/ | ||
|
||
using BH.oM.Base.Debugging; | ||
using BH.oM.Base.Attributes; | ||
using System.Linq; | ||
using System.ComponentModel; | ||
using System; | ||
|
||
namespace BH.Engine.Base | ||
{ | ||
public static partial class Compute | ||
{ | ||
/***************************************************/ | ||
/**** Public Methods ****/ | ||
/***************************************************/ | ||
|
||
[Description("Switch off the entire logging system used within BHoM. Any part of the code base which tries to log any note, warning, error, or other event into the log system will be housed in the silent recorder and not displayed to users. By default, all recording systems are turned on when BHoM is initialised.")] | ||
[Input("areYouSure", "Set this to true if you are sure you want to turn off all log recording. This boolean exists so that if this component is placed on a BHoM UI accidently, it does not turn off the system unless then expressly requested.")] | ||
public static void SwitchOffRecording(bool areYouSure) | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!areYouSure) | ||
return; | ||
|
||
m_RecordError = false; | ||
m_RecordWarning = false; | ||
m_RecordNote = false; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch off the entire logging system for ERRORS only. All other types of events will be recorded.")] | ||
[Input("areYouSure", "Set this to true if you are sure you want to turn off all ERROR log recording. This boolean exists so that if this component is placed on a BHoM UI accidently, it does not turn off the system unless then expressly requested.")] | ||
public static void SwitchOffRecordingErrors(bool areYouSure) | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!areYouSure) | ||
return; | ||
|
||
m_RecordError = false; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch off the entire logging system for WARNINGS only. All other types of events will be recorded.")] | ||
[Input("areYouSure", "Set this to true if you are sure you want to turn off all WARNING log recording. This boolean exists so that if this component is placed on a BHoM UI accidently, it does not turn off the system unless then expressly requested.")] | ||
public static void SwitchOffRecordingWarnings(bool areYouSure) | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!areYouSure) | ||
return; | ||
|
||
m_RecordWarning = false; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch off the entire logging system for NOTES only. All other types of events will be recorded.")] | ||
[Input("areYouSure", "Set this to true if you are sure you want to turn off all NOTE log recording. This boolean exists so that if this component is placed on a BHoM UI accidently, it does not turn off the system unless then expressly requested.")] | ||
public static void SwitchOffRecordingNotes(bool areYouSure) | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!areYouSure) | ||
return; | ||
|
||
m_RecordNote = false; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* This file is part of the Buildings and Habitats object Model (BHoM) | ||
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved. | ||
* | ||
* Each contributor holds copyright over their respective contributions. | ||
* The project versioning (Git) records all such contribution source information. | ||
* | ||
* | ||
* The BHoM is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3.0 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The BHoM is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. | ||
*/ | ||
|
||
using BH.oM.Base.Debugging; | ||
using BH.oM.Base.Attributes; | ||
using System.Linq; | ||
using System.ComponentModel; | ||
using System; | ||
|
||
namespace BH.Engine.Base | ||
{ | ||
public static partial class Compute | ||
{ | ||
/***************************************************/ | ||
/**** Public Methods ****/ | ||
/***************************************************/ | ||
|
||
[Description("Switch on the entire logging system used within BHoM. By default all recording systems are switched on when BHoM is initialised.")] | ||
public static void SwitchOnRecording() | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
m_RecordError = true; | ||
m_RecordWarning = true; | ||
m_RecordNote = true; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch on the entire logging system for ERRORS only. By default all recording systems are switched on when BHoM is initialised.")] | ||
public static void SwitchOnRecordingErrors() | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
m_RecordError = true; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch on the entire logging system for WARNINGS only. By default all recording systems are switched on when BHoM is initialised.")] | ||
public static void SwitchOnRecordingWarnings() | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
m_RecordWarning = true; | ||
} | ||
|
||
/***************************************************/ | ||
|
||
[Description("Switch on the entire logging system for NOTES only. By default all recording systems are switched on when BHoM is initialised.")] | ||
public static void SwitchOnRecordingNotes() | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
m_RecordNote = true; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.