summaryrefslogtreecommitdiff
path: root/src/journal/journalctl.c
AgeCommit message (Collapse)Author
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-11-17journalctl: don't print -- No entries -- in quiet modeEvgeny Vereshchagin
2015-11-12journald: rework --sync/--rotate logic to use CLOCK_MONOTONIC timestamp filesLennart Poettering
Previously, we'd rely on the mtime timestamps of the touch files to see if our sync/rotation requests were already suppressed. This means we rely on CLOCK_REALTIME timestamps. With this patch we instead store the CLOCK_MONOTONIC timestamp *in* the touch files, and avoid relying on mtime. This should make things more reliable when the clock or underlying mtime granularity is not very good. This also adds warning messages if writing any of the flag files fails.
2015-11-11journalctl: change repeated if checks into switch blocksLennart Poettering
No functional changes.
2015-11-11journalctl: refuse to --machine= in combination with --flush, --sync or --rotateLennart Poettering
2015-11-11journalctl: make --rotate synchronous, tooLennart Poettering
Of course, ideally we'd just use normal synchronous bus calls, but this is out of the question as long as we rely on dbus-daemon (which logs to journald, and thus cannot use to avoid cyclic sync loops). Hence, instead, reuse the wait logic already implemented for --sync, and use a signal in one direction, and a mtime watch file for the reply.
2015-11-11journalctl: add new --sync switch for syncing the journal to diskLennart Poettering
With this new "--sync" switch we add a synchronous way to sync everything queued to disk, and return only after that's complete. This command gives the guarantee that anything queued before has hit the disk before the command returns. While we are at it, also improve the man pages and help text for journalctl a bit.
2015-11-05treewide: use the negative error codes returned by our functionsMichal Schmidt
Our functions return negative error codes. Do not rely on errno being set after calling our own functions.
2015-11-03journalctl: when we fail to open a journal file, print whyLennart Poettering
When we enumerate journal files and encounter an invalid one, remember which this, and show it to the user. Note the possibly slightly surprising logic here: we store only one path per error code. This means we show all error kinds but not every actual error we encounter. This has the benefit of not requiring us to keep a potentially unbounded list of errors with their sources around, but can still provide a pretty complete overview on the errors we encountered. Fixes #1669.
2015-11-03journalctl: continue operation, even if we run into an invalid fileLennart Poettering
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: split out globbing related calls into glob-util.[ch]Lennart Poettering
2015-10-27util-lib: split out syslog-related calls into syslog-util.[ch]Lennart Poettering
2015-10-27util-lib: move more locale-related calls to locale-util.[ch]Lennart Poettering
2015-10-27util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering
2015-10-27util-lib: split out file attribute calls to chattr-util.[ch]Lennart Poettering
2015-10-27util-lib: split out resource limits related calls into rlimit-util.[ch]Lennart Poettering
2015-10-27util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering
2015-10-26util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering
2015-10-26util-lib: split out IO related calls to io-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24path-util: unify how we process paths specified on the command lineLennart Poettering
Let's introduce a common function that makes relative paths absolute and warns about any errors while doing so.
2015-10-22journalctl: clarify -q optionEvgeny Vereshchagin
-q suppresses info messages too
2015-10-13Merge pull request #1548 from evverx/journalctl-catalog-ops-fixesLennart Poettering
Fix journalctl --dump-catalog, journalctl --list-catalog
2015-10-13journalctl: introduce short options for --since and --untilJan Synacek
Fixes #1514.
2015-10-13journalctl: enable args for --dump-catalog and --list-catalogEvgeny Vereshchagin
`journalctl --dump-catalog ID1 ID2 ...` works fine.
2015-10-13journalctl: open pager for --dump-catalog and --list-catalogEvgeny Vereshchagin
2015-10-02journal: rework vacuuming logicLennart Poettering
Implement a maximum limit on number of journal files to keep around. Enforcing a limit is useful on this since our performance when viewing pays a heavy penalty for each journal file to interleve. This setting is turned on now by default, and set to 100. Also, actully implement what 348ced909724a1331b85d57aede80a102a00e428 promised: use whatever we find on disk at startup as lower bound on how much disk space we can use. That commit introduced some provisions to implement this, but actually never did. This also adds "journalctl --vacuum-files=" to vacuum files on disk by their number explicitly.
2015-10-01Merge pull request #1426 from poettering/log-syntaxDaniel Mack
logging fixes and more
2015-09-30tree-wide: remove a number of invocations of strerror() and replace by %mLennart Poettering
Let's clean up our tree a bit, and reduce invocations of the thread-unsafe strerror() by replacing it with printf()'s %m specifier.
2015-09-30journalctl: add --rotate optionEvgeny Vereshchagin
shortcut for `systemctl kill --kill-who main --signal SIGUSR2 systemd-journald`
2015-09-29bus-util: rename bus_open_transport() to bus_connect_transport()Lennart Poettering
In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus, while sd_bus_default_xyz() family tries to reuse the thread's default bus. bus_open_transport() sometimes internally uses the former, sometimes the latter family, but suggests it only calls the former via its name. Hence, let's avoid this confusion, and generically rename the call to bus_connect_transport(). Similar for all related calls. And while we are at it, also change cgls + cgtop to do direct systemd connections where possible, since all they do is talk to systemd itself.
2015-09-29util: introduce common version() implementation and use it everywhereLennart Poettering
This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
2015-09-22cgtop: underline table headerLennart Poettering
Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
2015-09-10tree-wide: never use the off_t unless glibc makes us use itLennart Poettering
off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.
2015-09-09tree-wide: make use of log_error_errno() return value in more casesLennart Poettering
The previous coccinelle semantic patch that improved usage of log_error_errno()'s return value, only looked for log_error_errno() invocations with a single parameter after the error parameter. Update the patch to handle arbitrary numbers of additional arguments.
2015-09-09tree-wide: make use of log_error_errno() return valueLennart Poettering
Turns this: r = -errno; log_error_errno(errno, "foo"); into this: r = log_error_errno(errno, "foo"); and this: r = log_error_errno(errno, "foo"); return r; into this: return log_error_errno(errno, "foo");
2015-08-17journalctl: make sure 'journalctl -f -t unmatched' blocksStef Walter
Previously the following command: $ journalctl -f -t unmatchedtag12345 ... would block when called with criteria that did not match any journal lines. Once log lines appeared that matched the criteria they were displayed. Commit 02ab86c732576a71179ce12e97d44c289833236d broke this behavior and the journal was not followed, but the command exits with '-- No entries --' displayed. This commit fixes the issue. More information downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1253649
2015-08-05Merge branch 'hostnamectl-dot-v2'Zbigniew Jędrzejewski-Szmek
Manual merge of https://github.com/systemd/systemd/pull/751.
2015-08-05hostname-util: get rid of unused parameter of hostname_cleanup()Zbigniew Jędrzejewski-Szmek
All users are now setting lowercase=false.
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-07-24journalctl: properly detect empty journal filesLennart Poettering
When we encounter a journal file with exactly zero entries, print a nice message and exit, and don't print a weird error message.
2015-07-03sd-bus: introduce new sd_bus_flush_close_unref() callLennart Poettering
sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush() (which writes all unwritten messages out) + sd_bus_close() (which terminates the connection, releasing all unread messages) + sd_bus_unref() (which frees the connection). The combination of this call is used pretty frequently in systemd tools right before exiting, and should also be relevant for most external clients, and is hence useful to cover in a call of its own. Previously the combination of the three calls was already done in the _cleanup_bus_close_unref_ macro, but this was only available internally. Also see #327
2015-05-19journalctl: unify how we free boot id lists a bitLennart Poettering
Instead of use LIST_FOREACH_SAFE, just use the same, seperate destructor everywhere.
2015-05-19journalctl: clean up how we log errorsLennart Poettering
All functions should either log the errors they run into, or only return them in which case the caller should log them. Make sure this rule is followed, so that each error is logged precisely once, and neither never, nor more than once.
2015-05-19journalctl: rename boot_id_t to BootIdLennart Poettering
So far we tried to reserve the _t suffix to types we use like a value in contrast to types we use as objects, hence let's do this in journalctl too.
2015-05-19journalctl: lstat() should suffice if we call canonicalize_file_name() firstLennart Poettering
2015-05-19journalctl: free all command line argument objectsLennart Poettering
let's try to be valgrind clean
2015-05-19journalctl: only have a single exit path from main()Lennart Poettering
That way we can be sure we execute the destructors properly, and can be valgrind-clean.
2015-05-19journalctl: Improve boot ID lookupJan Janssen
This method should greatly improve offset based lookup, by simply jumping from one boot to the next boot. It starts at the journal head to get the a boot ID, makes a _BOOT_ID match and then comes from the opposite journal direction (tail) to get to the end that boot. After flushing the matches and advancing the journal from that exact position, we arrive at the start of next boot. Rinse and repeat. This is faster than the old method of aggregating the full boot listing just so we can jump to a specific boot, which can be a real pain on big journals just for a mere "-b -1" case. As an additional benefit --list-boots should improve slightly too, because it does less seeking. Note that there can be a change in boot order with this lookup method because it will use the order of boots in the journal, not the realtime stamp stored in them. That's arguably better, though. Another deficiency is that it will get confused with boots interleaving in the journal, therefore, it will refuse operation in --merge, --file and --directory mode. https://bugs.freedesktop.org/show_bug.cgi?id=72601