[Gambas-user] how to log to stdout/stderr

Tobias Boege taboege at ...626...
Thu Jul 13 20:11:25 CEST 2017


On Thu, 13 Jul 2017, PICCORO McKAY Lenz wrote:
> how can i log to stdout and stderr my program actions/methods/things ?
> 
> note that due vendor/client i cannot use gambas 3.5+ only 3.4... due its
> the already installed..
> 
> some time ago benoit respond me that recent version of gambas implements
> something similar already,
> but i cannot find the main in the horrible sourgeforce heavyweith web
> interface
> 

The PRINT instruction writes to stdout (by default) and the ERROR
instruction to stderr (by default). There is also DEBUG which writes
to stderr and includes the filename, function name and line number
where it is executed at the beginning of the output. It is for print-
style debugging and if you don't compile the project with gbc3's
"-g" switch the DEBUG statements will NOT be compiled, so don't do
anything in those statements which could have side effects.

You can change the default stream PRINT and ERROR/DEBUG operate on
by OUTPUT TO and ERROR TO.

Those things must have been in Gambas since forever, there is by far
no 3.x version requirement. The more sophisticated (by always broken
when I tried it, IIRC) component gb.logging was added in Gambas 3.5,
but if you just want to print to stdout and stderr, there is no reason
to use it.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list