Shop OBEX P1 Docs P2 Docs Learn Events
SPIN - What do you use for logging info/errors? — Parallax Forums

SPIN - What do you use for logging info/errors?

Alex.StanfieldAlex.Stanfield Posts: 198
edited 2012-05-20 15:28 in Propeller 1
I'd like to know if anyone has a spin module for logging information/errors for debugging and also general logging.

Ideal would be to have the possibility to use a serial terminal for debugging (at development phase) and later on using the same module use it for logging information on a SD card.

I haven't found anything like that on obex

A function like
  fat.log(Severity, Message)

With
- "Severity" being a constant enumeration (Information/Warning/Error/Critical/etc)
- "Message" a user defined text string

This function would output to serial or a user defined file a whole line of text that includes at least the following fields separated with a defined char like space/commas/tabs/etc
- timestamp
- cog number (optional, but would help))
- Severity in clear text
- message

Any comments?

Alex

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2012-05-12 12:32
    I'm using FullDuplexSerial for debugging all the time.
    But not in such a sophisticated way that I have a log-method like yu described it above.

    The only thing I have in this direction is a method TaggedValue (string_pointer,value)
    the string says what the value is. In most cases just the variable-name of the variable.

    A complete different way of debugging is to use ViewPort whre you can read out every variable you want, showing the change of the value like on a scope
    and even single-step spin-code

    best regards
    Stefan
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2012-05-15 12:47
    I just uploaded to the OBEX a SYSLOG sub-system for helping in the debugging and logging under SPIN

    http://obex.parallax.com/objects/864/

    Provides a logging/debugging system that can store information from multiple cogs (running SPIN) into one file on a SD card, may optionally echo that information to a serial terminal.

    Echo to serial port may be turned on/off at run-time.

    Each cog may have it's own description in the log file for easily finding any given routine's output.

    Hope it helps get those programs up and running faster.

    Alex
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-05-15 13:03
    Wow Alex !

    that sounds great. Some years ago when I worked as a software developer for PC-based industrial controls
    I had such a log-system. But for the propeller I was much too lazy to code something like this.
    I haven't worked with your object but I want to thank you for sharing it.

    Before diving into it I have a question: for most apps the executiontime of the logging is not important.
    Anyway logging to SD-card or echoing to serial takes time.

    Would it be possible or easy to have some kind of a statevariable that is set to different values
    to keep the execution-time as low as one command-line like state := value and another cog is
    "listening" to the changes of that variable state and logging them with timestamp?

    best regards
    Stefan
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2012-05-15 13:47
    StefanL38 wrote: »
    Wow Alex !

    Would it be possible or easy to have some kind of a statevariable that is set to different values
    to keep the execution-time as low as one command-line like state := value and another cog is
    "listening" to the changes of that variable state and logging them with timestamp?

    best regards
    Stefan

    Thanks for your comments Stefan.

    Your idea sounds great. I guess it would require a cog with some address monitoring (the variable's address), detect the changes and then logging it. Will give it a try.

    thanks!
    Alex
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2012-05-20 15:28
    I just updated the SYSLOG object in OBEX

    http://obex.parallax.com/objects/864/

    I
    included a very basic variable watching routine. You only need to supply an address (LONG sized) and a variable name. Then it will keep watching and log the new value whenever it changes it's value.

    Since it's running under SPIN it will not capture all changes if they occur very rapidly, however it could be helpful anyway under some circumstances.

    Have fun

    Alex
Sign In or Register to comment.