Commit Graph
34 Commits
Author SHA1 Message Date
Joachim Wiberg 64e41e066b Change default loglevel to LOG_INFO from LOG_NOTICE
We've had several logit() messages of LOG_INFO level that never
really made it to syslog because we classified it as "debug".

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-22 17:20:17 +02:00
Jacques de Laval e91f1ea1b2 logging: Disregard logging facility when comparing log levels
If we don't extract the level (disregarding facility), statements such as
"logit(LOG_CONSOLE | LOG_NOTICE, ...)" would never reach the kernel log.

Signed-off-by: Jacques de Laval <Jacques.De.Laval@westermo.com>
2021-05-20 17:19:53 +02:00
Joachim Wiberg 522276b80d Minor, rename internal functions/variables screen_* -> tt*
- Shorter
 - Follows old UNIX tradition
 - Lines up with next commit

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-07 10:06:01 +02:00
Joachim Wiberg e0a65f67c9 Minor, staticify, reduce includes and allow debug to kmsg
The loglevel setting should control all logging, regardless of
where we target it.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-06 23:55:54 +01:00
Joachim Wiberg 4bcfd606b4 Refactor screen_init(), use methods developed in pimd project
- Refactor screen_init()
  - use native impl. of TTY probing from pimd project
    - check if TIOCWINSZ works
    - check if we're running in watch(1), for initctl
  - check if ANSI goto(999,999) escape seq. works (invasive)
  - fallback to 80x24
- Drop screen_exit()
- Rename screen_init() to get_width(), for now, matching pimd
- Relocate call in main() to banner(), first fn to write to TTY

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-04 23:23:31 +01:00
Joachim Wiberg 80e4f025d3 flog: new helper function for debugging to file
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-26 09:09:34 +01:00
Joachim Wiberg 939c6f2f67 Fix regression in displaying progress at runtime
We don't want to show progress (starting/stopping/restaring) at
runtime, since Finit v3.  Many systems hooked up to a console
get confused by sudden output, or even ansi escape sequences.

This patch drops code added recently which caused a regression
in this policy.  The resulting code is even more readable.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-25 00:22:01 +01:00
Joachim Wiberg 70ca64a392 New cmdline options to control debug and progress/status
Modeled after systemd.show_status, currently without the 'auto' setting.

- finit.debug[=bool]
- finit.show_status[=bool]
- finit.status_style[=old,classic,new,modern]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 20:11:45 +01:00
Joachim Wiberg 35e4e0d073 Drop confusing splash cmdline and --enable-progress configure option
This patch reverts back to the progress/status behavior of Finit < v3.0
because this is what most users expect, including the maintainer.  The
resulting code and configure script is a lot simpler to understand and
maintain:

- No more --enable-progress or --enable-progress-classic configure
  flags.  Instead a progress_style variable in helpers.c that can
  be changed at compile time for those that really need it.
- No more 'splash' kernel commnand line option.  This turned out to
  be *very* confusing to many users who believed it was some sort of
  graphical splash screen à la Plymouth.

Also, when Finit debug is enabled we now have a global 'debug' flag
which now alo controls if klogctl() should be called to prevent the
kernel logs to the console or not.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-14 20:11:08 +01:00
Joachim Wiberg a5714a058c Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:07:03 +01:00
Joachim Wiberg 24a78d3246 Update copyright years and author last name
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2020-09-02 23:38:11 +02:00
Joachim Nilsson 225510a270 Remove gratuitous newline when finit stops its own log service
This patch fixes an annoying thing when typing reboot/shutdown/poweroff
that caused an extra newline to be printed before displaying services
stopping.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-30 18:29:45 +01:00
Joachim Nilsson eeb13dba74 Toggle silent mode (progress) when toggling debug mode
Starting in debug mode and disabling debug at runtime did not exhibit
the same behavior as if starting in normal mode and toggling debug mode
at runtime.  This patch adds toggling of silent mode (progress output)
to runtime debug toggling.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-23 09:44:44 +01:00
Joachim Nilsson 3d20237959 Follow-up to f858d94, only reinitialize screen when toggling debug mode
The screen_init() call for each print() & C:o caused serious screen
artefacts in debug mode.  This patch reworks f858d94 to only re-init
screen when toggling debug.

Also, avoid screen_init() completely if started in debug mode.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-23 09:33:24 +01:00
Joachim Nilsson f858d94d2a Reinitialize screen at shutdown and when in debug mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-16 14:47:14 +01:00
Joachim Nilsson 71915e0e14 Make sure log_exit() restores progress output on shutdown/reboot
This patch builds on top of the recently introduced "silent by default"
and support for kernel cmdline `splash` to disable silent operation.

At shutdown/reboot `log_exit()` is called, the intention is to re-enable
progress output so the user can see what's going on.  So, we need to re-
set `silent` to the same setting as log_init() started with, hence the
new `muffler()`.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-04 11:16:58 +01:00
Joachim Nilsson 5309ece2f9 Add support for splash progress mode from kernel cmdline
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-30 21:28:30 +01:00
Joachim Nilsson f7c0366fa2 Fix segfault on X86_64, call va_end()+va_start() for each vfprintf()
... varargs is a special kind of hell.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-23 00:38:01 +01:00
Joachim Nilsson 77cd0f0243 Fix problem with duplicate log messages before syslogd has started
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-13 17:58:48 +01:00
Joachim Nilsson c1bd3961cf log_init(): If called with debug disbled set (or restore) LOG_NOTICE
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-08 00:11:24 +02:00
Joachim Nilsson 4fa47eaf71 log_init(): If debug mode enabled, set loglevel LOG_DEBUG
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-08 00:08:27 +02:00
Joachim Nilsson e5f47024af early_logit(): If debug mode enable, also print to stderr
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-08 00:07:49 +02:00
Joachim Nilsson e46e3cdcb6 log.c: Filter debug messages by default, like before refactor
Ways to log:
- Set debug, using kernel cmdline, or edit the sources
- Change loglevel severity, default blocks > LOG_NOTICE

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 21:56:19 +02:00
Joachim Nilsson 516dbcc512 Remove --disable-quiet and quiet mode, default to a sane behavior
This patch is a follow-up to 1f1c2e0 which introduced the new semantics
for the very confusing quiet and silent modes.

The initial idea was to loosely follow the kernel cmdline 'quiet' option
and as a working concept this was good.  The resulting code, however,
became unnecessarily complex and the configure options impossible to
explain.

With this patch the quiet mode, and thus the --disable-quiet configure
option, is removed.  Finit now defaults to a sane behavior: services are
shown only at startup.   The --enable-silent option works like it did
before, silencing everything.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 13:40:54 +02:00
Joachim Nilsson 7a48240856 log.c: Do reopen syslog() when toggling debug => LOG_PERROR
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 13:19:22 +02:00
Joachim Nilsson cd947a69a8 log.c: New functions to hide access to quiet and silent flags
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:42:44 +02:00
Joachim Nilsson 51e1a907e6 log.c: New log_is_debug() function, hide access to debug variable
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:40:50 +02:00
Joachim Nilsson bd54cf6dee log.c: New log_init() function, called at initial bootstrap
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:34:12 +02:00
Joachim Nilsson 1036c365b8 log.c: New log_exit() function, called at shutdown
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:31:38 +02:00
Joachim Nilsson 8ce330bcdb log.c: Rename log_toggle_debug() --> log_debug()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:28:16 +02:00
Joachim Nilsson ec52a6a240 Set correct syslog() log level based on debug flag
Also, refactor logging to /dev/kmsg to separate function.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-01 22:23:53 +02:00
Joachim Nilsson 5e8cb63f9a Refactor, _d() et al to use logit() instead of err.h
This patch is the first in a series of changes to clean up the internal
logging APIs of Finit:

  1. Convert log macros to use logit() for everything (this patch)
  2. Set correct syslog() log level based on debug flag
  3. Do closelog()/openlog() when toggling debug flag to control LOG_PERROR

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-01 20:34:37 +02:00
Joachim Nilsson d1df837d04 Refactor, move debug toggle to log.c:log_toggle_debug()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-01 20:34:37 +02:00
Joachim Nilsson 670f08ce51 Refactor, move logit() and log macros to log.c + log.h
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-01 20:34:37 +02:00