Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: All-purpose reusable logger unit

  1. #11

    Exclamation

    Hi,

    while writing the demo I found that the switch function isn't doing well with udt variables.

    Anyway, here is the last version that raise an error at switch keyword.

    Eros, do you think it is worth waiting for a fix or to workaround that in the meantime ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  2. #12

    Thumbs up

    Quote Originally Posted by DirectuX View Post
    Hi,

    while writing the demo I found that the switch function isn't doing well with udt variables.

    Anyway, here is the last version that raise an error at switch keyword.

    Eros, do you think it is worth waiting for a fix or to workaround that in the meantime ?
    Very curiously, workaround is EASY.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  3. #13

    Cool

    Well,

    fix_feat_severity is now the latest version.

    Every functionality is now working thanks to workarounds. (errors reported)

    There is a demo too.
    Last edited by DirectuX; 05-01-2020 at 23:07.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  4. #14
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Sebastian,

    thanks a lot for the additions. I really appreciate you integrated the changed, thank you!

    If I may, few ideas - not requests - just ideas.

    When I see line like this:
    dim logger as tLogthis(%TRUE, %TRUE, %FALSE, %FALSE)
    
    ... I feel a bit anxious - what was the first boolean flag, what second, what third, what fourth? This is why I would recommend to solve situation like this with a single binary mask instead.

    Also, I noticed that the parameter #1, isDebug, contradicts parameter #4, verbose.

    From "code smell" perspective, it is recommended to avoid negative flags. Instead of doNotPrependTag, I would preffer prependTag. This was mentioned in Code Complete, it is a really nice book with lot of good advices.

    I would suggest to not overdo it with parameters in constructor, and provide convenient defaults, overridable by methods:
    dim logger as tLogthis()
    logger.showConsole(true)
    logger.setOutputMode(%LOG_MODE_DEBUG) # or %LOG_MODE_VERBOSE
    logger.prependTag(false)
    
    Too much typing? Yes, but you do it once, for setup. Readability? In my opinion much higher than %TRUE, %TRUE, %FALSE, %FALSE.

    Last but not least, I think .logThis could be replaced with .write, it is a bit shorter and does not look too verbose.

    Let me know what you think.


    Petr
    Last edited by Petr Schreiber; 06-01-2020 at 22:38.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #15
    Hi Petr,,

    Last but not least, I think .logThis could be replaced with .write, it is a bit shorter and does not look too verbose.
    Yes ! Thanks !

    Instead of doNotPrependTag, I would preffer prependTag
    I perfectly agree, but then I have to take time to think how, as I wanted prependTag by optional default. Did you have something in mind ?

    When I see line like this:
    dim logger as tLogthis(%TRUE, %TRUE, %FALSE, %FALSE)
    
    I feel a bit anxious - what was the first boolean flag, what second, what third, what fourth?
    Here again I agree.
    1/ Not an excuse but it may help understand my bad habit: with VB6, there always was a filtered auto suggest list along typing : so not room for error or questioning parameters.
    2/ Did you just suggest what I did for this part ? :

    'logWhere equates
    %LT_Debug = 1 as Long 'Display only if isDebug = %TRUE
    %LT_Time = 2 as Long ' Prepend DateTime$
    %LT_ToConsole = 4 as Long
    %LT_ToConsoleTitle = 8 as Long
    %LT_ToMsgBox = 16 as Long
    %LT_ToLogFile= 32 as long
    %LT_ToStatusBar= 64 as long
    
    (...)
    
    function logThis(logWhere as long = 0, (...)
    
    if Bit_Get(logWhere,1) then
    
    if yes, that's ok and easy (readability part) but
    for code writing, it remains the same until we do something for code auto suggestions.

    Did I understand your idea ?



    Quote Originally Posted by Petr Schreiber View Post
    Hi Sebastian,

    thanks a lot for the additions. I really appreciate you integrated the changed, thank you!

    If I may, few ideas - not requests - just ideas.

    When I see line like this:
    dim logger as tLogthis(%TRUE, %TRUE, %FALSE, %FALSE)
    
    ... I feel a bit anxious - what was the first boolean flag, what second, what third, what fourth? This is why I would recommend to solve situation like this with a single binary mask instead.

    How?

    Compare the readability of this:
    dim logger as tLogthis(%LOG_DEBUG | %LOG_SHOWCONSOLE)
    
    Also, from "code smell" perspective, it is recommended to avoid negative flags. Instead of doNotPrependTag, I would preffer prependTag. This was mentioned in Code Complete, it is a really nice book with lot of good advices.

    Last but not least, I think .logThis could be replaced with .write, it is a bit shorter and does not look too verbose.

    Let me know what you think.


    Petr
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  6. #16
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    I perfectly agree, but then I have to take time to think how, as I wanted prependTag by optional default. Did you have something in mind ?
    You can make prependTag OPTIONAL, but you can still give the parameter default value via `= true` or `= false`.

    Not an excuse but it may help understand my bad habit: with VB6, there always was a filtered auto suggest list along typing : so not room for error or questioning parameters.
    I understand your point with filling parameters, but it still is and issue when reading the code

    Did you just suggest what I did for this part ?
    Yes, but I then changed my mind because of the exclusivity between isDebug and verbose. Please see the edited post.


    Thank you,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #17

    Thumbs up

    Hi,

    @Petr, thank you again for your guidance

    Master is now again the most up to date version of this Log unit.

    To do: documentation, thus code is self explaining ( demo is present ).
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  8. #18
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Thank you for the adjustments, Sebastian

    It is looking good! I think we have a solid, highly customizable base here.

    For quick logging, I would maybe like to have something like:
    dim logger as tLogThis()
    logger.SetDefaultLogTarget(%LT_ToMsgBox + %LT_ToConsole) ' If not specified other, these would be used. Stores parameter to me.defaultLogTarget internally
    logger.SetDefaultTitle("Main")                           ' If not specified other, this title would be used. Stores parameter to me.defaultTitle internally
    
    
    logger.wInfo("Ciao, Sebastian!")                         ' Internally calls logger.write(me.defaultLogTarget, "Ciao, Sebastian", me.defaultTitle, %TAG_INFO)
    logger.wError("Ooops, problem happened")                 ' Internally calls logger.write(me.defaultLogTarget, "Ooops, problem happened", me.defaultTitle, %TAG_ERROR)
    
    What do you think?

    Petr
    Last edited by Petr Schreiber; 07-01-2020 at 21:23.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  9. #19
    Great idea Petr !

    As I'm already on another thinBasic project, I logged the idea and be back soon on this.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  10. #20
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    If you can add "thinBasic" word somewhere in https://github.com/DirectuX/logger readme.md it will be found when people search for thinBasic.

    Thanks
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Lerp2 purpose ?
    By DirectuX in forum Math
    Replies: 2
    Last Post: 30-12-2019, 10:04
  2. Log007 - lightweight logger with license to kill
    By Petr Schreiber in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 2
    Last Post: 29-03-2016, 19:01
  3. Point2D + Point2DCollection: Reusable units for your projects
    By Petr Schreiber in forum User files and/or user projects
    Replies: 0
    Last Post: 14-06-2015, 21:07
  4. HEAP_Extended-Unit
    By ReneMiner in forum General purpose scripts
    Replies: 0
    Last Post: 23-09-2013, 09:01
  5. General Purpose Eval
    By JosephE in forum Eval
    Replies: 15
    Last Post: 10-05-2011, 21:31

Members who have read this thread: 1

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •