Skip to content

Use logger for messaging #6

@sheljohn

Description

@sheljohn
  • Remove +verb/ submodule, in favour of using the dk.logger.Logger implementation.
  • Default logger should be created at startup.
  • Additional function dk.logger.level to simplify level control.
  • Alias method Logger:setFile, more explicit than open.
  • Implement static class dk.logger.test to be called by assert/reject in order to redirect assertions to different channels.
  • Remove static method callerInfo from Logger, and move it to separate dk.logger.chan instead (taking stack depth argument), which returns a struct with channel ID and caller string.
  • Update Logger:write to take a channel as first input, and exclude empty caller from log line.
  • Implement function dk.log, taking a channel as first input (or creating a default one if formatted message is passed directly), with a persistent instance of the default logger.
funciton log(varargin)
    persistent..

    args = varargin;
    if nargin  > 1
        v = args{1};
        if isstruct(v)
            chan = v;
            args = varargin(2:end);
        elseif ismember(v,{'w','e','...'})
            chan = dk.logger.chan( v, 4 );
            args = varargin(2:end);
        else
            chan = dk.logger.chan( 'i', 4 );
        end
    end
    L.write( chan, args{:} );
end
  • Refactor functions dk.warn/info to call dk.log
  • Remove ..if methods from Logger, in favour of directed assertions.
  • Replace calls to dk.wassert/wreject with calls to assert with specified channels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions