summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Bump symbol versionsHEADlibumberlog-0.3.0masterGergely Nagy2012-08-131-11/+3
| | | | | | | Since we had an ABI bump, maintaining old symbol versions is pointless unless we'd maintain the SONAME too. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Preparations for 0.3.0Gergely Nagy2012-08-111-2/+2
| | | | | | | Bump the version in configure.ac, and the library version in lib/Makefile.am, in preparation for the upcoming 0.3.0 release. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Preparations for 0.3.0.Gergely Nagy2012-08-111-1/+1
| | | | | | | The next version will be 0.3.0, due to the significant - and incompatible - changes made so far. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* LOG_UL_NODISCOVER => LOG_UL_NOIMPLICITGergely Nagy2012-08-113-15/+16
| | | | | | | | Based on a suggestion by Miloslav Trmač <mitr@redhat.com>, rename LOG_UL_NODISCOVER to LOG_UL_NOIMPLICIT, and clarify the documentation slightly. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Support disabling discovery for the LD_PRELOAD variantGergely Nagy2012-08-102-2/+9
| | | | | | | | When compiled with --disable-discovery, the LD_PRELOAD variant will have automatic field discovery disabled. This does not affect the linkable library, which always has them enabled by default. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Introduce LOG_UL_ALLGergely Nagy2012-08-102-0/+5
| | | | | | | This new flag for ul_set_log_flags() makes it easier to understand what the default is (0 typically does not mean "enable all"). Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Caching-related documentation updateGergely Nagy2012-08-101-10/+10
| | | | | | | Describe it better how caching works (and also correct a few mistakes that were left over when ul_set_log_flags() was introduced). Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Introduce ul_set_log_flags()Gergely Nagy2012-08-104-13/+38
| | | | | | | | | | | | | | Instead of piggy-backing on ul_openlog(), and accepting new flags at openlog()-time, use a separate function, ul_set_log_flags() to achieve the same. This way, anyone who wants to flip any of the new flags, will have to use ul_set_log_flags(), as ul_openlog() ignores them from now on. This is based on work done by Miloslav Trmač <mitr@redhat.com>, and is both an API and an ABI breakage. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Split the library into a linkable and an LD_PRELOAD-able partGergely Nagy2012-08-104-44/+89
| | | | | | | | | | | | In order to satisfy the desire of using libumberlog, specifically ul_format(), without having to worry about syslog() & friends being overridden, split the library into two parts: A linkable library, which provides the new API, but does not override the legacy syslog() functions; and a new, LD_PRELOAD-able part, which does override the old ones. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Documentation updateGergely Nagy2012-08-101-2/+1
| | | | | | | | ul_closelog() does not clear flags anymore, in order to mimic closelog() better, so remove the note about clearing from the API docs. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Greatly simplify ul_openlog()Gergely Nagy2012-08-101-12/+22
| | | | | | | | | | Instead of checking the flags for LOG_UL_NODISCOVER in every branch, check it once in the beginning for LOG_UL_NODISCOVER | LOG_UL_NOCACHE, and bail out early. This greatly improves the readability of the code. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Whitespace & coding style cleanupGergely Nagy2012-08-101-5/+6
| | | | Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Rebuild libumberlog.la when the link script changesMiloslav Trmač2012-07-301-0/+1
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Add an explicit cast to avoid a warningMiloslav Trmač2012-07-301-1/+1
| | | | | | ... with -Wsign-compare. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Remove some unused variables.Miloslav Trmač2012-07-301-3/+1
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Add prototypes to old_*Miloslav Trmač2012-07-301-4/+4
| | | | | | to minimize the risk of type mistakes. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix ul_recurse indicator, again.Miloslav Trmač2012-07-301-1/+1
| | | | | | | | Don't reset ul_recurse before exiting a recursive invocation. Apparently I have send this patch before, followed by a patch that immediately reverts it, so resending. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Don't set up caches if UL_NO_DISCOVER is setMiloslav Trmač2012-07-301-4/+4
| | | | | | We won't need the data in that case. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Mark missing host name separately from flags.Miloslav Trmač2012-07-301-7/+13
| | | | | | | | | | | This simplifies the syslog() path a little, and allows us to express "host name should be cached but no value is set.". Because host name field is already emptied by default and in closelog (), this also means uncached data is used before openlog () and after closelog (). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Initialize [UG]ID to "no value cached"Miloslav Trmač2012-07-301-3/+3
| | | | | | | Now syslog () without openlog () will include a correct [UG]ID value instead of 0. Also reset the cache on closelog (). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Mark missing [UG]ID cache data separately from flags.Miloslav Trmač2012-07-301-14/+25
| | | | | | | This simplifies the syslog() path a little, and allows us to express "[UG]ID should be cached but no value is set.". Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix return type of _get_gid ()Miloslav Trmač2012-07-301-1/+1
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Initialize PID to "no value cached"Miloslav Trmač2012-07-301-2/+2
| | | | | | | Now syslog () without openlog () will include a correct PID value instead of 0. Also reset the cache on closelog (). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Mark missing PID cache data separately from flags.Miloslav Trmač2012-07-301-6/+12
| | | | | | | This simplifies the syslog() path a little, and allows us to express "PID should be cached but no value is set.". Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Move the caches into ul_process_dataMiloslav Trmač2012-07-301-19/+25
| | | | | | None of the cache items is thread-specific. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Don't reset flags on closelog()Miloslav Trmač2012-07-301-1/+0
| | | | ... to be compatible with BSD syslog.
* Make "flags" a per-process variableMiloslav Trmač2012-07-301-12/+12
| | | | | | ... to match openlog(3p). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Default ident (log tag) to program_invocation_short_nameMiloslav Trmač2012-07-301-3/+18
| | | | | | | This is a glibc variable, so leave the "program" field missing on platforms that don't support it. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Don't include "program": "(null)" if ident is not setMiloslav Trmač2012-07-301-1/+6
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Make "ident" (log tag) a per-process variableMiloslav Trmač2012-07-301-4/+7
| | | | | | ... to comply with openlog(3p). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Don't reset facility on closelog()Miloslav Trmač2012-07-301-3/+0
| | | | | | | This is not defined by closelog(3p), and the BSD implementation doesn't do it either. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Change the default facility to LOG_USER.Miloslav Trmač2012-07-301-2/+2
| | | | | | ... to comply with openlog(3p). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Make "facility" set by ul_openlog() per-processMiloslav Trmač2012-07-302-3/+17
| | | | | | ... to match openlog(3). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Rename ul_sys_settings to ul_thread_dataMiloslav Trmač2012-07-301-25/+25
| | | | | | | | ... to clarify its scope, and account for caches contained there. Next commit will add per-process data, and having the smaller-scope structure named "sys" would be confusing. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Leave printf format parsing to glibc if possible.Gergely Nagy2012-07-192-7/+98
| | | | | | | | | | | | | Call glibc's parse_printf_format() to gather information about argument types. This automatically handles positional parameters and user-defined printf formats for ordinary parameter types; it doesn't handle user-defined printf parameter types (such as defined by libdfp for decimal floating-point). Also add a (non-comprehensive) test. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Whitespace cleanupGergely Nagy2012-07-191-104/+104
| | | | | | | Replace tabs introduced by the last couple of merged commits with spaces. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Handle more types in printf()-like specifiersMiloslav Trmač2012-07-192-2/+48
| | | | | | | Recognize more length modifiers. Document that positional parameters are not supported (it should be possible, I'm just lazy :)). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Let libc manage the syslog mask.Miloslav Trmač2012-07-181-12/+3
| | | | | | | | | | | | | | | | | | | glibc has a per-process, not per-thread, syslog mask, so the per-thread mask in ul_sys_settings may end up desynchronized from the glibc mask, breaking compatibility for LD_PRELOAD. Just call setlogmask (0) to always read the glibc mask, and drop the per-thread cache. An alternative is to use a per-thread mask for ul_* calls and to use the glibc mask for the LD_PRELOAD-overridden functions, but that seems to be unnecessarily complex. ul_setlogmask () is now a trivial wrapper, so we don't need to override setlogmask () at all. We could also drop ul_setlogmask () completely, but that would break the API. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix ul_recurse indicatorMiloslav Trmač2012-07-181-1/+1
| | | | | | Don't reset ul_recurse before exiting a recursive invocation. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix a memory leak on error pathsMiloslav Trmač2012-07-181-4/+3
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix checking of vasprintf() return valueMiloslav Trmač2012-07-181-1/+1
| | | | | | | The (res == NULL) check below should not be necessary per (info libc), but doesn't hurt, so I have left it in. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Add helper function _ul_vasprintf_and_advanceMiloslav Trmač2012-07-181-22/+26
| | | | | | ... simplifying the callers of _ul_va_spin. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Make _ul_va_spin a function.Miloslav Trmač2012-07-181-75/+76
| | | | | | | | It is not safe to pass va_list into a function, but we can pass a pointer. Do this so that we don't have to keep two copies of the code in a large macro. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Use a local variable instead of parameter for va_listMiloslav Trmač2012-07-181-11/+26
| | | | | | | | In functions that use _ul_va_spin, use a local variable instead of a parameter. This commit is not useful stand-alone, but will be necessary for the next one (and makes the next one easier to review). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Eliminate some duplicate codeMiloslav Trmač2012-07-181-12/+5
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Switch warn_unused_result attributesMiloslav Trmač2012-06-221-5/+5
| | | | | | | | These should not be on ul_*syslog, because there is nothing one can do to recover; OTOH they should be on ul_*format, because they indicate a memory leak. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix log mask handlingMiloslav Trmač2012-06-221-1/+1
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Fix timestamp formattingMiloslav Trmač2012-06-221-1/+1
| | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* Remove escape_buffer entirelyGergely Nagy2012-06-221-25/+7
| | | | | | | | | | | | Output the escaped content directly into the destination buffer, avoiding the memory copy and associated overhead. This finishes the series, and brings another 6.6-18.0% speed improvement in test_perf, compared to the previous increase with using a static exception map. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Escape values directly into a bufferGergely Nagy2012-06-221-25/+55
| | | | | | | | Instead of precomputing a buffer length, do only one pass, extending the buffer as necessary. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Signed-off-by: Gergely Nagy <algernon@balabit.hu>