summaryrefslogtreecommitdiff
path: root/src/shared/log.c
Commit message (Collapse)AuthorAge
* shared/log: read /proc/cmdline only in daemonsZbigniew Jędrzejewski-Szmek2015-02-05
| | | | http://lists.freedesktop.org/archives/systemd-devel/2015-February/027960.html
* core: don't reset log level to NOTICE if we get quiet on the kernel cmdlineLennart Poettering2015-02-04
| | | | | | | | | | | | | | | | quiet should really just have an effect on the stuff we dump on the console, not what we log elsewhere. Hence: debug on kernel cmdline → interpreted by every tool, turns up log levels to "debug" everywhere. quiet on kernel cmdline → interpreted only by PID 1 (and obviously the kernel) no alteration of the max log level, but turns off status output. http://lists.freedesktop.org/archives/systemd-devel/2014-December/026271.html
* Add a snprinf wrapper which checks that the buffer was big enoughZbigniew Jędrzejewski-Szmek2015-02-01
| | | | | | | | | | If we scale our buffer to be wide enough for the format string, we should expect that the calculation was correct. char_array_0() invocations are removed, since snprintf nul-terminates the output in any case. A similar wrapper is used for strftime calls, but only in timedatectl.c.
* Assorted format fixesZbigniew Jędrzejewski-Szmek2015-01-22
| | | | | Types used for pids and uids in various interfaces are unpredictable. Too bad.
* log: add new log output mode, that prints to console, but prefixes with ↵Lennart Poettering2015-01-22
| | | | | | | syslog priority This is useful when we execute our own programs, reading output from its STDERR, and want to retain priority information.
* log: change log_xyz_errno() calls to always return the negative errorLennart Poettering2014-11-28
| | | | | | | | | | | | | | | | This enables us to write things like this: int open_some_file(void) { fd = open("/dev/foobar", O_RDWR|O_CLOEXEC); if (fd < 0) return log_error_errno(errno, "Failed to reboot: %m"); return fd; } Which is function that returns -errno on failure, as well as printing an error message, all in one line.
* log: make socket address structs static constLennart Poettering2014-11-28
|
* log: also set errno to the passed error code before processing format string ↵Lennart Poettering2014-11-28
| | | | | | in log_struct() That way the caller may use %m to print the specified error.
* log: allow negative errno valuesLennart Poettering2014-11-28
| | | | | sd_bus_error_set_errno() allows negative errors too, hence, be equally nice.
* log: rearrange log function namingLennart Poettering2014-11-27
| | | | | | | | | | - Rename log_meta() → log_internal(), to follow naming scheme of most other log functions that are usually invoked through macros, but never directly. - Rename log_info_object() to log_object_info(), simply because the object should be before any other parameters, to follow OO-style programming style.
* log: be a bit less wasteful when allocating buffersLennart Poettering2014-11-27
|
* log: add an "error" parameter to all low-level logging calls and intrdouce ↵Lennart Poettering2014-11-27
| | | | | | | | | | | | | | | | | | | | log_error_errno() as log calls that take error numbers This change has two benefits: - The format string %m will now resolve to the specified error (or to errno if the specified error is 0. This allows getting rid of a ton of strerror() invocations, a function that is not thread-safe. - The specified error can be passed to the journal in the ERRNO= field. Now of course, we just need somebody to convert all cases of this: log_error("Something happened: %s", strerror(-r)); into thus: log_error_errno(-r, "Something happened: %m");
* log: unchecked return value from librarySusant Sahani2014-11-17
| | | | fix 1237557 Unchecked return value from library
* log: explicitly ignore return value of parse_proc_cmdline()Lennart Poettering2014-11-07
| | | | CID# 1251162
* sd-bus,log: remove unused variablesThomas Hindoe Paaboel Andersen2014-08-16
|
* main,log: parse the log related kernel command line parameters at one place ↵Lennart Poettering2014-08-15
| | | | | | | | | | | | | only, and for all tools Previously, we ended up parsing some of them three times: in main.c when processing the kernel cmdline, in main.c when processing the process cmdline (only for containers), and in log.c again. Let's streamline this, and only parse them in log.c In PID 1 also make sure we parse "quiet" first, and then override this with the more specific checks in log.c
* log: never ever log to syslog from PID 1, log to the journal againLennart Poettering2014-08-11
| | | | | We don't support journal-less systems anyway, so let's avoid the confusion.
* Properly report invalid quoted stringsZbigniew Jędrzejewski-Szmek2014-07-31
| | | | | | | | $ systemd-analyze verify trailing-g.service [./trailing-g.service:2] Trailing garbage, ignoring. trailing-g.service lacks ExecStart setting. Refusing. Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument. Failed to create trailing-g.service/start: Invalid argument
* Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek2014-07-31
| | | | | | | | | | | | | | | | | | | | | | String which ended in an unfinished quote were accepted, potentially with bad memory accesses. Reject anything which ends in a unfished quote, or contains non-whitespace characters right after the closing quote. _FOREACH_WORD now returns the invalid character in *state. But this return value is not checked anywhere yet. Also, make 'word' and 'state' variables const pointers, and rename 'w' to 'word' in various places. Things are easier to read if the same name is used consistently. mbiebl_> am I correct that something like this doesn't work mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"' mbiebl_> systemd seems to strip of the quotes mbiebl_> systemctl status shows mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint mbiebl_> which is pretty weird
* Add quotes to warning messageZbigniew Jędrzejewski-Szmek2014-07-20
| | | | The message for SYSTEMD_LOG_LEVEL= looked a bit strange.
* log: don't downgrade log level in non-PID 1 if "quiet" is passed on kernel ↵Lennart Poettering2014-06-17
| | | | | | cmdline "debug" should apply to all tools, but "quiet" only to PID1.
* log: honour the kernel's quiet cmdline argumentRonny Chevalier2014-06-10
| | | | | | It was forgotten in b1e90ec515408aec2702522f6f68c4920b56375b See https://bugs.freedesktop.org/show_bug.cgi?id=79582
* Remove unnecessary casts in printfsZbigniew Jędrzejewski-Szmek2014-05-15
| | | | No functional change expected :)
* util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering2014-03-18
| | | | | | | | | | | | | | | safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
* Make tables for DEFINE_STRING_TABLE_LOOKUP consistentDaniel Mack2014-03-07
| | | | | | | | Bring some arrays that are used for DEFINE_STRING_TABLE_LOOKUP() in the same order than the enums they reference. Also, pass the corresponding _MAX value to the array initalizer where appropriate.
* macro: introduce a nice macro for disabling -Wformat-nonliteral temporarilyLennart Poettering2014-02-20
|
* Pass log config from systemd to systemd-shutdownZbigniew Jędrzejewski-Szmek2014-02-17
| | | | | | | If PID 1 debug logging is enabled, it is nice to keep those settings when switching to systemd-shutdown binary, independently of whether this was done through /proc/cmdline options, or through runtime manipulations.
* journald: log provenience of signalsZbigniew Jędrzejewski-Szmek2014-02-11
|
* log: als turn on debug logging in non-PID1 if /proc/cmdline contains "debug"Lennart Poettering2013-12-23
|
* logging: reduce send timeout to something more sensibleZbigniew Jędrzejewski-Szmek2013-12-20
| | | | | | For a user, the timeout of 1 min per message seems equivalent to a hang. If journald cannot process a message from PID1 for 10 ms then something is significantly wrong. It's better to lose the message and continue.
* log: when we log to /dev/console and got disconnected (maybe due to vhangup) ↵Lennart Poettering2013-12-18
| | | | reconnect
* log: don't reopen /dev/console each time we call log_open()Lennart Poettering2013-12-18
| | | | Instead, force reopen it only if we really really have to.
* _noreturn_ --> noreturn for C11 compatShawn Landden2013-12-17
| | | | also define noreturn w/o <stdnoreturn.h>
* log: protect errno when we use assert_return()Lennart Poettering2013-12-12
|
* Do not log all assert_return failuresZbigniew Jędrzejewski-Szmek2013-12-11
| | | | | | | % build/journalctl help Assertion 'match_is_valid(data, size)' failed at ../src/journal/sd-journal.c:227, function sd_journal_add_match(). Ignoring. Callers cannot be expect to check all arguments always.
* macro: log assertion at debug level in assert_return()Lennart Poettering2013-12-10
|
* core: synchronously block when loggingLennart Poettering2013-07-24
| | | | | | | | | | | | | Previously, the logging sockets were asynchronous and if clogged we'd lose messages. We did this to be extra careful given that PID 1 might need to spawn the logging daemon as response to PID 1's own log messages and we really should avoid a deadlock in that case. As it turns out this causes loss of too many messages, hence make the socket blocking again, however put a time limit on it to avoid unbounded deadlocks in the unlikely case they happen. https://bugs.freedesktop.org/show_bug.cgi?id=66664
* core/main: use _cleanup_Zbigniew Jędrzejewski-Szmek2013-04-17
|
* Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek2013-04-05
| | | | | | | | | | | | | | | | | | | | | | | Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
* util: add a bit of syntactic sugar for saving/restoring errnoLennart Poettering2013-04-02
|
* Revert "log: fix fallbacks to kmsg"Lennart Poettering2013-02-27
| | | | | | | | | | | | | | | | This reverts commit 4a01181e460686d8b4a543b1dfa7f77c9e3c5ab8. This patch broke LOG_TARGET_AUTO, i.e. automatic selection of STDERR if it is a TTY with a fallback on the journal and kmsg otherwise. The general rule should probably be: log_open() -- open the "best" possible logging channel according to log_target configuration. log_dispatch() -- don't open any log channels ever, with the exception of kmsg since that has no drawbacks. And do this only on true errors of the better log channel, not just when it wasn't opened.
* log: fix fallbacks to kmsgMichal Schmidt2013-02-16
| | | | | | write_to_journal() returns 0 if journal_fd is closed and nothing is written. We need to make sure we'll try log_open_kmsg() then to make the fallback work for "journal-or-kmsg".
* share/log: skip file/line/func info if emptyZbigniew Jędrzejewski-Szmek2013-01-18
| | | | | The new microhttpd logger doesn't know this information. It is better to log nothing than fake values.
* share/log: unify two code pathsZbigniew Jędrzejewski-Szmek2013-01-18
| | | | | | Explicit zeroing is replaced with initialization to {0}. No functional change.
* journal: new logging macros to include UNIT=Zbigniew Jędrzejewski-Szmek2013-01-06
| | | | | | | | | | | | | Adding UNIT= to log lines allows them to be shown in 'systemctl status' output, etc. A new set of macros and functions is added. This allows for less verbose notation than using log_struct() explicitly. The set of logging functions is expanded to take a pair of arguments (e.g. "UNIT=" and the RHS) which add an extra line to the structured log entry. This can be used to add macros which add a different identifier later on.
* log: fix repeated invocation of vsnprintf()/vaprintf() in log_struct()Lennart Poettering2012-09-24
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=55213
* shared: call va_end in all casesLukas Nykryn2012-09-21
|
* log: avoid function loopLennart Poettering2012-09-17
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=54766
* build-sys: __secure_getenv lost dunder in libc 2.17Zbigniew Jędrzejewski-Szmek2012-09-17
|
* journal: suppress structured messages if they'd go to the consoleLennart Poettering2012-09-03
|