how to log to stdout/stderr

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to log to stdout/stderr

PICCORO McKAY Lenz
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


Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

Tobias Boege-2
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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

PICCORO McKAY Lenz
hello toby, when i set the gambas binary to backgroud to runs as daemon
...and lauch other gambas process from that gambas ...

then the stdout and stderr does not have that behaviour you said!
so then?

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-07-13 14:11 GMT-04:00 Tobias Boege <[hidden email]>:

> 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
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

Tobias Boege-2
On Thu, 13 Jul 2017, PICCORO McKAY Lenz wrote:
> hello toby, when i set the gambas binary to backgroud to runs as daemon
> ...and lauch other gambas process from that gambas ...
>
> then the stdout and stderr does not have that behaviour you said!
> so then?
>

You're wrong, it does exactly what you wanted and specifically asked about:
print to stdout and stderr.

As we discussed recently [1], stdout and stderr are redirected to /dev/null
when you daemonise, so there is not really any value in wanting to print
there if you want to make a daemon.

If you still want the output of your system daemon to arrive somewhere, you
have to point stdout and stderr to somewhere meaningful again, like your
syslog. You can also make your own log files as was discussed in [1], if you
don't have a real *system* daemon that should be integrated into the systemd
(or what have you) ecosystem. There is information available about this on
the net [2], which is completely independent of Gambas, BTW.

There's an(other) old saying: If you want a good answer you have to ask a
very good question.

Regards,
Tobi

[1] https://sourceforge.net/p/gambas/mailman/gambas-user/thread/1498036647346-59450.post%40n7.nabble.com/#msg35904830
[2] https://stackoverflow.com/questions/17954432/creating-a-daemon-in-linux

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

PICCORO McKAY Lenz
ok, thanks.. that's the mail ([1])

the problem of make right answer its the languaje barrier.. in my countrie
its very spensive make a english course, and internet connection are very
slowly and spensive too

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-07-13 16:11 GMT-04:00 Tobias Boege <[hidden email]>:

> On Thu, 13 Jul 2017, PICCORO McKAY Lenz wrote:
> > hello toby, when i set the gambas binary to backgroud to runs as daemon
> > ...and lauch other gambas process from that gambas ...
> >
> > then the stdout and stderr does not have that behaviour you said!
> > so then?
> >
>
> You're wrong, it does exactly what you wanted and specifically asked about:
> print to stdout and stderr.
>
> As we discussed recently [1], stdout and stderr are redirected to /dev/null
> when you daemonise, so there is not really any value in wanting to print
> there if you want to make a daemon.
>
> If you still want the output of your system daemon to arrive somewhere, you
> have to point stdout and stderr to somewhere meaningful again, like your
> syslog. You can also make your own log files as was discussed in [1], if
> you
> don't have a real *system* daemon that should be integrated into the
> systemd
> (or what have you) ecosystem. There is information available about this on
> the net [2], which is completely independent of Gambas, BTW.
>
> There's an(other) old saying: If you want a good answer you have to ask a
> very good question.
>
> Regards,
> Tobi
>
> [1] https://sourceforge.net/p/gambas/mailman/gambas-user/
> thread/1498036647346-59450.post%40n7.nabble.com/#msg35904830
> [2] https://stackoverflow.com/questions/17954432/creating-a-
> daemon-in-linux
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

Fernando Cabral
In reply to this post by Tobias Boege-2
2017-07-13 17:11 GMT-03:00 Tobias Boege <[hidden email]> said:

> As we discussed recently [1], stdout and stderr are redirected to /dev/null
> when you daemonise, so there is not really any value in wanting to print
> there if you want to make a daemon.


I don't know if I have understood you correctly and completely.
 I am an old timer and Linux may have changed things as compared to UNIX.
A daemon is supposed to run in the background. Typically, when you put
something to
run in the background, Unix would send the standard output to... standard
output.

Now, if you do "nohup something.gambas", standard outuput will to to
"nohup.out".
But, if you do "nohup something.gambas >x &" or "something.gambas >x",
standard output wll be sent to "x".

In any case, if you don't want to preserve any output, you should redirect
stderr and
stdout to /dev/null.

I would guess that a daemon started at startup or by cron would give the
same result.
Am I wrong?

Regards

- fernando

> [1] https://sourceforge.net/p/gambas/mailman/gambas-user/
> thread/1498036647346-59450.post%40n7.nabble.com/#msg35904830
> [2] https://stackoverflow.com/questions/17954432/creating-a-
> daemon-in-linux
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

PICCORO McKAY Lenz
in part you have right fernando.. but that was dicuss several time
previously.. i want to no made special commands to daemonize my app.. i
want my app are daemon by selft..

now my app are a property daemon.. and every night at 00:00 restart all
setting and starts a new day to regist people..

the log must also be manage by the application.. if not then its not a
proper daemon..

the nohup trick not always work.. for that there's the gambas redirection
print.. that's why i ask previously how i detec if are runnig inside ide..
if are inside ide. let normal print, if not, redirect...

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-07-13 19:54 GMT-04:00 Fernando Cabral <[hidden email]>:

> 2017-07-13 17:11 GMT-03:00 Tobias Boege <[hidden email]> said:
>
> > As we discussed recently [1], stdout and stderr are redirected to
> /dev/null
> > when you daemonise, so there is not really any value in wanting to print
> > there if you want to make a daemon.
>
>
> I don't know if I have understood you correctly and completely.
>  I am an old timer and Linux may have changed things as compared to UNIX.
> A daemon is supposed to run in the background. Typically, when you put
> something to
> run in the background, Unix would send the standard output to... standard
> output.
>
> Now, if you do "nohup something.gambas", standard outuput will to to
> "nohup.out".
> But, if you do "nohup something.gambas >x &" or "something.gambas >x",
> standard output wll be sent to "x".
>
> In any case, if you don't want to preserve any output, you should redirect
> stderr and
> stdout to /dev/null.
>
> I would guess that a daemon started at startup or by cron would give the
> same result.
> Am I wrong?
>
> Regards
>
> - fernando
>
> > [1] https://sourceforge.net/p/gambas/mailman/gambas-user/
> > thread/1498036647346-59450.post%40n7.nabble.com/#msg35904830
> > [2] https://stackoverflow.com/questions/17954432/creating-a-
> > daemon-in-linux
> >
> > --
> > "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
>
>
> --
> Fernando Cabral
> Blogue: http://fernandocabral.org
> Twitter: http://twitter.com/fjcabral
> e-mail: [hidden email]
> Facebook: [hidden email]
> Telegram: +55 (37) 99988-8868
> Wickr ID: fernandocabral
> WhatsApp: +55 (37) 99988-8868
> Skype:  fernandojosecabral
> Telefone fixo: +55 (37) 3521-2183
> Telefone celular: +55 (37) 99988-8868
>
> Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
> nenhum político ou cientista poderá se gabar de nada.
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to log to stdout/stderr

Fernando Cabral
2017-07-13 21:21 GMT-03:00 PICCORO McKAY Lenz <[hidden email]>:

> the nohup trick not always work.. for that there's the gambas redirection
> print.. that's why i ask previously how i detec if are runnig inside ide..
> if are inside ide. let normal print, if not, redirect...
>
> I am not sure I have understood what you said. What I can say is that, for
logging purpose, you can just open a regular file and then write to or
append to.

In order to determine if your application is running as a daemon or not, if
can be quite easy and fool proof. For intance, you can create a command
line options like, say "-d". If it is present, your applicaiton should run
as a daemon, so you act accordingly. Otherwise the application is not
running as daemon, so you should act as a regular application.

As to printing (if you mean, printing to a printer proper) you can either
open a pipe to the printer daemon or else create a file and then use a
shell () instruction to print and delete that file. Both should work well.

- fernando




> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2017-07-13 19:54 GMT-04:00 Fernando Cabral <[hidden email]>:
>
> > 2017-07-13 17:11 GMT-03:00 Tobias Boege <[hidden email]> said:
> >
> > > As we discussed recently [1], stdout and stderr are redirected to
> > /dev/null
> > > when you daemonise, so there is not really any value in wanting to
> print
> > > there if you want to make a daemon.
> >
> >
> > I don't know if I have understood you correctly and completely.
> >  I am an old timer and Linux may have changed things as compared to UNIX.
> > A daemon is supposed to run in the background. Typically, when you put
> > something to
> > run in the background, Unix would send the standard output to... standard
> > output.
> >
> > Now, if you do "nohup something.gambas", standard outuput will to to
> > "nohup.out".
> > But, if you do "nohup something.gambas >x &" or "something.gambas >x",
> > standard output wll be sent to "x".
> >
> > In any case, if you don't want to preserve any output, you should
> redirect
> > stderr and
> > stdout to /dev/null.
> >
> > I would guess that a daemon started at startup or by cron would give the
> > same result.
> > Am I wrong?
> >
> > Regards
> >
> > - fernando
> >
> > > [1] https://sourceforge.net/p/gambas/mailman/gambas-user/
> > > thread/1498036647346-59450.post%40n7.nabble.com/#msg35904830
> > > [2] https://stackoverflow.com/questions/17954432/creating-a-
> > > daemon-in-linux
> > >
> > > --
> > > "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> > >
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Gambas-user mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> >
> >
> >
> > --
> > Fernando Cabral
> > Blogue: http://fernandocabral.org
> > Twitter: http://twitter.com/fjcabral
> > e-mail: [hidden email]
> > Facebook: [hidden email]
> > Telegram: +55 (37) 99988-8868
> > Wickr ID: fernandocabral
> > WhatsApp: +55 (37) 99988-8868
> > Skype:  fernandojosecabral
> > Telefone fixo: +55 (37) 3521-2183
> > Telefone celular: +55 (37) 99988-8868
> >
> > Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
> > nenhum político ou cientista poderá se gabar de nada.
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...