ralphwetzel / theonionbox

Dashboard to monitor Tor node operations
MIT License
122 stars 17 forks source link

Log messages emits to screen on FreeBSD #56

Closed rainlance closed 5 years ago

rainlance commented 5 years ago

Log messages does not emit to syslog but to console (tty/stdout). With a working log handler, messages are emitted both to log and to console.

Thank you for supporting FreeBSD in The Onion Box !!

ralphwetzel commented 5 years ago

By default, log messages shall emit to console (only). If The Onion Box is operated as a service, log messages are emitted to syslog (only).

Do you observe this pattern of operation - or a different one?

rainlance commented 5 years ago

Log messages are emitted to console even when The Onion Boxoperated as a service. Pull request #61 fixes the issue.

ralphwetzel commented 5 years ago

@rainlance: Thank you for providing a PR. Unfortunately this just suppresses the messages to be emitted to stdout - yet they are not (re)directed to syslog:

daemon(8): -f Redirect standard input, standard output and standard error to /dev/null.

https://github.com/ralphwetzel/theonionbox/commit/30289103a63ed2b3406b1c46945f9ff1e94a979c was committed to add this redirecting functionality to the launcher script for FreeBSD. Could you please verify if this works, as I don't have a test system available currently.

@yurivict: If confirmed, there is another dependency that needs to be taken care of: logger.

yurivict commented 5 years ago

The redirect is wrong for the Bourne shell https://github.com/ralphwetzel/theonionbox/commit/30289103a63ed2b3406b1c46945f9ff1e94a979c#diff-c441889cc16437ae2d8b40dc1ec6e662R50

$ sudo service theonionbox onestart
eval: 1: Syntax error: redirection unexpected (expecting word)
eval: 1: Syntax error: Error in command substitution
rainlance commented 5 years ago

@ralphwetzel Tor behaves exactly the same way as The Onion Box emitting messages directly to the shell during startup. So I guess this behavior should be OK. It is just unusual for service on FreeBSD to act like this. They usually only emit messages to their own logs or one of the systems logs.

There is some background info in the handbook on the topic: https://www.freebsd.org/doc/handbook/configtuning-syslog.html

yurivict commented 5 years ago

IMO, the right way is to have a command line option to use system log, and to use a python library to write to it.

rainlance commented 5 years ago

I agree @yurivict. Seems like FreeBSD needs a dedicated SysLogHandler. Here is an Python example using the logging.getLogger() method: https://forums.freebsd.org/threads/python-sysloghandler-no-working.61049/

ralphwetzel commented 5 years ago

@rainlance My expectation is that a service send his output to syslog. I'm surprised that Tor, as you describe, emits to stdout. The Onion Box shall use syslog, when running as a service.

@yurivict A(nother) dedicated command line option adds complexity, especially for inexperienced users. Thus I'd rather find a way to transparently redirect stdout/stderr to syslog, even if it needs some iterations. Perhaps you could check if https://github.com/ralphwetzel/theonionbox/commit/2e95ba9a109450624a00d7812d3f669197550718 performs better...