Difference between revisions of "Program Examples:sys log"

From SoftMC-Wiki
Jump to: navigation, search
Line 32: Line 32:
 
<br/>
 
<br/>
 
{{Note/Important|Debug level can be set by using telnet}}
 
{{Note/Important|Debug level can be set by using telnet}}
 
+
<br/>
 
A log message at debug level MC_BASIC_LOG_LEVEL_ERROR will always be displayed in sys.log.<br/>
 
A log message at debug level MC_BASIC_LOG_LEVEL_ERROR will always be displayed in sys.log.<br/>
A log message at debug level MC_BASIC_LOG_LEVEL_DEBUG will be displayed in sys.log if the debug level MC-BASIC in softMC is set to DEBUG.<br/>
+
A log message at debug level MC_BASIC_LOG_LEVEL_DEBUG will be displayed in sys.log if the debug level of MC-BASIC in softMC is set to DEBUG.<br/>
  
log_str - A log string in printf format<br/>
+
log_str - A string in printf format<br/>
  
 
arg1 to arg10 - Variables of type <u>LONG</u> that correspond with log_str printf format string. Unused arguments can be set to zero.<br/>
 
arg1 to arg10 - Variables of type <u>LONG</u> that correspond with log_str printf format string. Unused arguments can be set to zero.<br/>

Revision as of 09:05, 31 December 2014

'sys.log' is a Linux logger that allows the programmer to document strings while his program is running. We've enabled this feature in MC-Basic context as well.

Printing sys.log

To print sys.log do the following: 1. Connect to the softMC using ssh or serial console.
2. To print the entire log, type in the Linux terminal:

-bash-3.2$ cat /var/sys.log

or
3. To print the last few lines, type in the Linux terminal:

-bash-3.2$ tail -50 /var/sys.log

where '50' is the number of lines that will be printed from the end of the file.

display last 20 lines of sys.log

Sending strings to sys.log

Globally load the MC library SYSLOG.LIB. Invoke the function
log_msg(byval debug_level as long, byval log_str as string, byval arg1 as long, arg2, arg3..., arg10) as long
Where the arguments are:

debug_level - Use one of the following constants:

MC_BASIC_LOG_LEVEL_NON = 0
MC_BASIC_LOG_LEVEL_ERROR = 1
MC_BASIC_LOG_LEVEL_WARNING = 2
MC_BASIC_LOG_LEVEL_NOTE = 3
MC_BASIC_LOG_LEVEL_DEBUG = 4
MC_BASIC_LOG_LEVEL_ALL = 5

IMPORTANT.svgIMPORTANT
Debug level can be set by using telnet


A log message at debug level MC_BASIC_LOG_LEVEL_ERROR will always be displayed in sys.log.
A log message at debug level MC_BASIC_LOG_LEVEL_DEBUG will be displayed in sys.log if the debug level of MC-BASIC in softMC is set to DEBUG.

log_str - A string in printf format

arg1 to arg10 - Variables of type LONG that correspond with log_str printf format string. Unused arguments can be set to zero.