DEBUGFG macro (log groups)
Page 1 of 1

Author:  dunkaist [ Wed Dec 28, 2016 5:07 am ]
Post subject:  DEBUGFG macro (log groups)


I wrote a macro I wanted for a long time. It took 10 lines and a few hours:
macro DEBUGFG _level, _group, _format, [_arg] {
  if _group eqtype
   DEBUGF _level, _format,_arg
   if _level >= _group
    DEBUGF 999, _format,_arg
   end if
  end if

This macro introduces so called log groups, a method to combine debug messages into logical groups to set their log level on per group basis.

Here is a simple example:
Spoiler: Show
    org 0x0
    db  'MENUET01'
    dd  0x01,start,i_end,e_end,e_end,0,0

__DEBUG__ = 1

LOG_FLOW equ 1
LOG_CALC equ 3

include '../../../'
include '../../../'

        DEBUGFG 1, LOG_FLOW, '1 flow\n'
        DEBUGFG 2, LOG_FLOW, '2 flow\n'
        DEBUGFG 3, LOG_FLOW, '3 flow\n'

        DEBUGFG 1, LOG_CALC, '1 calc\n'
        DEBUGFG 2, LOG_CALC, '2 calc\n'
        DEBUGFG 3, LOG_CALC, '3 calc\n'

        DEBUGFG 1, LOG_SEND, '1 send\n'
        DEBUGFG 2, LOG_SEND, '2 send\n'
        DEBUGFG 3, LOG_SEND, '3 send\n'

        DEBUGF 1, '1 blah\n'
        DEBUGF 2, '2 blah\n'
        DEBUGF 3, '3 blah\n'

        mov     eax, -1
        int     0x40


rb 0x100        ;stack

On debug board:
1 flow
2 flow
3 flow
3 calc
2 send
3 send
2 blah
3 blah

The macro works as follows:
  • If you specify log level for a group, it overrides __DEBUG_LEVEL__ for this particular group;
  • If you don't specify group log level, __DEBUG_LEVEL__ is used (calls DEBUGF);
  • If you misspelled group name, fasm will report an error.
$ fasm loggroups.asm loggroups
flat assembler  version 1.71.58  (16384 kilobytes memory)
loggroups.asm [23]:
        DEBUGFG 3, LOG_CLAC, '3 calc\n'
../../../ [380] DEBUGFG [5]:
   if _level >= _group
processed: if 3>=LOG_CLAC
error: undefined symbol 'LOG_CLAC'.

I hope this new macro will be useful for you.

Author:  Pathoswithin [ Wed Dec 28, 2016 12:55 pm ]
Post subject:  Re: DEBUGFG macro (log groups)

It certainly could be useful... if you write a commentary about its arguments (or a one-string example). Same for the other macros. Cause each time I look into the I see a shit, so it's totally useless for me.

Page 1 of 1 All times are UTC+03:00
Powered by phpBB® Forum Software © phpBB Limited