Log facility
Previous topic  First topic  Next topic


Marinas-GUI has a function that help you to show a message and write it into a log file in a very simple way.
Optionally, you can suppress the message and only write the file log.

The function is:

lSuccess := mg_log( [ <xMessage> ] [ , <lDisplayMessage> ] [ , <lAddProgramStack> ] [ , <lForceEditBox> ] )

Where:

(Optional) <xMessage>: is a message in any format (String, Numeric, Hash, Array, Date, etc). Default is NIL

(Optional) <lDisplayMessage>: Use this parameter to suppress the display message. Default is .T.

(Optional) <lAddProgramStack>: Add stack program to message. Default is .F.

(Optional) <lForceEditBox>: When the message is short, the function display message in a mg_msgInfo(), but when the message is too long, the function display the message in a modal window with a EDITBOX. Coding .T. to this parameter force use EDITBOX instead mg_msgInfo() for all messages length

Its return .F. if its didn't write the file log or .T. if success

Samples:

1)
mg_log()

Show a mg_msgInfo() whitout message and write file log with line number (procLine())

2)
mg_log( "Hello World" )

Show a mg_msgInfo() with the "Hello World" message and write file log with message and line number (procLine())

3)
mg_log( "Hello World" , .F. )

Don't show any message but write file log with "Hello World" message and line number (procLine())

4)
mg_log( "Hello World" , , .T. )

Show a mg_msgInfo() with the "Hello World" message and write file log with message, line number (procLine()) and program stack

5)
mg_log( "Hello World" , , , .T. )

Show a modal window with the "Hello World" message and write file log with message and line number (procLine())


Sample log file:


2015/03/31 19:34:17 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(37): Hello World 1
2015/03/31 19:34:21 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(38): Hello World 2
2015/03/31 19:34:23 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(39): Hello World 3
2015/03/31 19:34:25 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(40): Hello World 4
2015/03/31 19:34:25 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(41): Hello World 5


Sample log file with program stack:

Program Stack:
Called from log.prg[TEST(42)]
Called from log.prg[(b)MAIN(25)]
Called from mg_core.prg[__MG__EXECBLOCK(2633)]
Called from mg_core.prg[(b)__MG_SETSLOT(15710)]
Called from QEVENTLOOP:PROCESSEVENTS(0)
Called from mg_core.prg[__MG_EVENTLOOPAPPL(15747)]
Called from mg_core.prg[__MG_PROPERTYMETHOD(4289)]
Called from mg_core.prg[MG_DO(4024)]
Called from log.prg[MAIN(31)]
2015/03/31 19:34:26 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(42): Hello World a
Program Stack:
Called from log.prg[TEST(43)]
Called from log.prg[(b)MAIN(25)]
Called from mg_core.prg[__MG__EXECBLOCK(2633)]
Called from mg_core.prg[(b)__MG_SETSLOT(15710)]
Called from QEVENTLOOP:PROCESSEVENTS(0)
Called from mg_core.prg[__MG_EVENTLOOPAPPL(15747)]
Called from mg_core.prg[__MG_PROPERTYMETHOD(4289)]
Called from mg_core.prg[MG_DO(4024)]
Called from log.prg[MAIN(31)]
2015/03/31 19:34:28 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(43): Hello World b
Program Stack:
Called from log.prg[TEST(44)]
Called from log.prg[(b)MAIN(25)]
Called from mg_core.prg[__MG__EXECBLOCK(2633)]
Called from mg_core.prg[(b)__MG_SETSLOT(15710)]
Called from QEVENTLOOP:PROCESSEVENTS(0)
Called from mg_core.prg[__MG_EVENTLOOPAPPL(15747)]
Called from mg_core.prg[__MG_PROPERTYMETHOD(4289)]
Called from mg_core.prg[MG_DO(4024)]
Called from log.prg[MAIN(31)]
2015/03/31 19:34:28 Thread: 0 Type: GUI Name: __mg_MainThread Stack(10) TEST(44): Hello World c



There is other useful function called mg_allStr( <xValue> ), this function is used to convert any value to string

e.g: mg_log( "This is the hash with information: " + mg_allStr( hMyHash ) + " and was made " + mg_allStr( nOccurs ) + "times" )



Redirecting Log File

You can change the log file location by coding:

SET MARINAS LOG TO <cFolderOrFile>

Note: the function mg_setLogFileName( <cFolderOrFile> ) take the same action

You can get the file name of marinas log with:

GET MARINAS LOG TO <cVarName>

Note: the function mg_getLogFileName() take the same action


Note: It is not recomended to use this file outside of mg_log() function



Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: April 27
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic