Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: All-purpose reusable logger unit

  1. #1

    Lightbulb All-purpose reusable logger unit

    Hi,

    I wrote a little unit for logging purposes.

    All comments welcome.

    https://github.com/DirectuX/logger

    Sample and documentation soon.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

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

    thanks a lot for working on this!

    I noticed two things:
    - the LOG type function collides with LOG keyword in thinBASIC (I get "Function name is a reserved key") for this example:
    #include "https://raw.githubusercontent.com/DirectuX/logger/master/LOG.tbasicu"
    
    
    dim logger as tLogThis
    
    
    logger.log("Hello")
    
    - from other programming languages I am used to concept of different log severities. For example debug, info, warning, error - not sure how to apply it here

    I do appreciate you implement advanced stuff like log rotation


    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

  3. #3
    Thank you for the feedback Petr.

    I'll take it into account and adjust the code soon. I've choose 'Log' because I wanted it to be short. Will rename.

    About severity, I have just implemented the 'important' flag which brighten the text colour in the console. Indeed I have seen these levels (debug, info, warning, error) before. I'll improve the code in this direction.

    Log rotation is to complete, currently log file splits to a new one after maxSize and backup the previous. It lacks the old file deleting part. I'm still thinking about it. If to use the new FSO_DeleteByAge function ? But what bothers me is that you can't delete to the trash. I would prefer a move to trash rather than delete.

    What do you think about these two behaviour ?

    • Manage log rotation by size : after n files split, delete the oldest. n grows and remain constant.
    • Manage log rotation by date : log files are deleted after a fixed time.



    Quote Originally Posted by Petr Schreiber View Post
    Sebastian,

    thanks a lot for working on this!

    I noticed two things:
    - the LOG type function collides with LOG keyword in thinBASIC (I get "Function name is a reserved key") for this example:
    #include "https://raw.githubusercontent.com/DirectuX/logger/master/LOG.tbasicu"
    
    
    dim logger as tLogThis
    
    
    logger.log("Hello")
    
    - from other programming languages I am used to concept of different log severities. For example debug, info, warning, error - not sure how to apply it here

    I do appreciate you implement advanced stuff like log rotation


    Petr
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    what a coincidence: I was working on a thinBasic module for logging.
    A kind of all in one purpose able to log on console/file/syslog/database/WS/...

    At office I have a lot of thinBasic scripts doing many different things (from data ETL to SFTP to Web Service calling and other things) and each has its own logging system.
    I wanted a centralized log to being able to analyze them all in one admin console.

    I was starting from SysLog protocol https://tools.ietf.org/html/rfc5424
    and was testing using https://syslogwatcher.com/

    Inspired by https://nlog-project.org/

    Actually I'm studying rfc5424 syslog protocol

    Will share soon.
    Last edited by ErosOlmi; 04-01-2020 at 18:26.
    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

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by DirectuX View Post
    If to use the new FSO_DeleteByAge function ? But what bothers me is that you can't delete to the trash. I would prefer a move to trash rather than delete.

    Good point. Will check what I can do.
    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

  6. #6
    Hi Eros,

    that's a shame we were not aware each other of the work in progress. Now, I wonder the point with this unit if you're baking a module ?

    A kind of all in one purpose able to log on console/file/syslog/database/WS/...
    That's the point of this unit ( target is : console / file / msgbox / statusbar / richedit ).

    I was starting from SysLog protocol
    I've just started improving the code in this direction since Petr's feedback (severity advice).
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I think it is worth to go on in parallel because we are working on similar matters but in different directions.

    My intent for the moment is to have a Syslog thinBasic compiled module only working for myself in the company.
    It will work using UDP at first and then TCP.
    When mature and working fine I will release as source code in Github.

    Instead you are making a great thinBasic source code library easy to be used and studied by anyone willing to develop using thinBasic
    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

  8. #8
    ok

    I've already made the modifications I talked previously here (severity and reserved keyword conflict). Now writing a little demo.

    Also, I'm working with Resources_Test001.tbasic sample on understanding the workflow with #ressources, DIALOG NEW and callbacks. It is not obvious for me at the moment.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by DirectuX View Post
    Also, I'm working with Resources_Test001.tbasic sample on understanding the workflow with #ressources, DIALOG NEW and callbacks. It is not obvious for me at the moment.
    Fault is from my side because I'm still experimenting and didn't give any advice on how to use.
    Anyway if you right click on line
    #resource ".\Resources_Test001.rc"
    
    you should get menu with "Open <resouce file name>"
    If you choose it a resource editor should open and you can edit/create forms
    .RC file is a common development file format used in some programming languages like C
    Forms and controls names defined in .RC file are than recognized at runtime by thinBasic engine and you can use in script.
    Not all controls are still developed, only few of them.

    I'm still try to find right direction.
    But better to spin off and talk into another thread.
    Last edited by ErosOlmi; 04-01-2020 at 21:46.
    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

  10. #10
    Thanks Eros,

    I'll use it for the statusbar demo.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Page 1 of 3 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
  •