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

set global verbosity #136

Open
ryancoe opened this issue May 4, 2020 · 3 comments
Open

set global verbosity #136

ryancoe opened this issue May 4, 2020 · 3 comments
Labels
cleanup/useability Improvements to structure, etc. proposal A proposal, for discussion with the development team src Improvements or additions to the source code

Comments

@ryancoe
Copy link
Member

ryancoe commented May 4, 2020

As mentioned in #134, it would be nice to have a single means of setting the verbosity level of WecOptTool. For example, in general most minor warnings (BEM results needing minor correction, the creation of directories, etc.) will be silenced. If the user somehow increases the verbosity level (e.g., WecOptTool.setVerbosity(1)), the warnings will be displayed. This could also increase the level of plotting.

This could be accomplished via method shown here: https://www.mathworks.com/help/matlab/matlab_prog/suppress-warnings.html#btmrdj8-4, where you can turn a warning with the ID WecOptTool:MyWarning off by calling warning('off','WecOptTool:MyWarning'). We could perhaps create a function WecOptTool.setVerbosity with something like the following:

function setVerbosity(verbLevel)
% setVerbosity(verbLevel)
%
% ...

if nargin < 1
   verbLevel = 0;
end

switch verbLevel
   case 0
      wset = 'off';
   case 1
      wset = 'on';
end

% every time you add a warning to a function within WecOptTool, add it to this list
warnIdList = {'WecOptTool:MyWarning', 'WecOptTool:AnotherWarning',...};

for ii = 1:length(warnIdList)
    warning(wset, warnIdList{ii})
end
@ryancoe ryancoe added the cleanup/useability Improvements to structure, etc. label May 4, 2020
@H0R5E
Copy link
Member

H0R5E commented May 5, 2020

This is sort of trying to create an adhoc logging system. Is there anything more formal in MATLAB? Apparently not. We might consider leaning on something like this:

https://www.mathworks.com/matlabcentral/fileexchange/37701-log4m-a-powerful-and-simple-logger-for-matlab

This would allow different levels of messages to be put in the code, is easily configurable and we wouldn't have to remember to update a list of warning identifiers.

@H0R5E H0R5E added the proposal A proposal, for discussion with the development team label May 5, 2020
@ryancoe
Copy link
Member Author

ryancoe commented May 5, 2020

log4m looks like a potential solution. I suppose the benefit of that over what I suggested is that you send the warnings to .txt file instead of the command console, which may be faster? and perhaps less intrusive. From what I can tell the license of log4m would not be prohibitive.

The downside of log4m is that MATLAB users are not accustomed to looking for log files and expect to see the relevant output in the command window.

Definitely a bit of a toss-up. I guess I'm partial to sending the warnings to the command window.

@H0R5E
Copy link
Member

H0R5E commented May 6, 2020

Yeah, it can log to console too but it's based on writing to a file and using a file is bad with the PCT (Nothing I've looked at is claiming to be thread safe <- probably why MATLAB hasn't done this). I found logging4matlab which doesn't need a file, but it would be important to check it works under the PCT. I can have a fiddle with this once we get this into a target. If logging4matlab doesn't fly then your solution might be the best we can do.

@H0R5E H0R5E added the src Improvements or additions to the source code label Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup/useability Improvements to structure, etc. proposal A proposal, for discussion with the development team src Improvements or additions to the source code
Projects
None yet
Development

No branches or pull requests

2 participants