summaryrefslogtreecommitdiffstats
path: root/lib/cee-syslog.c
Commit message (Collapse)AuthorAgeFilesLines
* Rename the project to libumberlogGergely Nagy2012-03-231-377/+0
| | | | Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Implement wrappers for __syslog_chk, when appropriate.Gergely Nagy2012-03-221-0/+33
| | | | | | | | | | | | | When compiled with __USE_FORTIFY_LEVEL, software using <syslog.h> will use the __syslog_chk function instead of syslog(), so we need to wrap that too. To do this properly, the library will wrap __syslog_chk when built with fortification, and use that from both the syslog() and the __syslog_chk() overrides. If built without, it will use the standard syslog() function. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Check (v)asprintf() return values.Gergely Nagy2012-03-221-2/+4
| | | | | | | If (v)asprintf() returns an error, abort() away, because we can't possibly proceed. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Add the timestamp to the JSON payload too.Gergely Nagy2012-03-211-0/+25
| | | | | | Add high-precision timestamp to the JSON payload (unless disabled). Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Include the hostname in the JSON payload.Gergely Nagy2012-03-211-0/+13
| | | | | | | Include the hostname (as returned by gethostname()) in the JSON payload. Test case updated to verify this. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Export the syslog() wrapper as cee_legacy_syslog()Gergely Nagy2012-03-211-5/+5
| | | | | | | For documentation purposes, and for clarity, export the syslog() wrappers under a sensible name. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Implement UID/GID discovery.Gergely Nagy2012-03-201-1/+27
| | | | | | | | | | | We now cache the uid and gid upon openlog(), and add it to the automatic fields unless discovery is disabled. The caching can be turned off by passing either the LOG_CEE_NOCACHE or the LOG_CEE_NOCACHE_UID flag to openlog(). The latter also disables caching the gid. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Add the identity to the automatically added fields.Gergely Nagy2012-03-201-0/+3
| | | | | | | | | The identity, as set by the first argument to openlog() can be cached away, and later used as the program name (that's pretty much how syslogds treat it, too), so add it to the list of automatically discovered fields. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
* Implement a wrapper for setlogmask()Gergely Nagy2012-03-201-2/+22
| | | | | | | | Since we'd like to avoid doing useless work during logging, wrap setlogmask() too, and save the mask set, so during _cee_vsyslog(), we can bail out early, if our priority is not set in the mask. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
* Implement LOG_CEE_NOCACHE & LOG_CEE_NODISCOVER handlingGergely Nagy2012-03-201-1/+13
| | | | | | | | | When LOG_CEE_NODISCOVER is set during openlog(), then don't do any discovery, not even when the value is cached. When _NOCACHE is set, then do not use the cached values for properties that can change during runtime, and their new value can be detected at runtime too. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
* Implement the new syslog() overrides.Gergely Nagy2012-03-201-19/+123
| | | | | | | | | | | | | | | | | | | | Changed the API, so that we have cee_(v)syslog(), which is the enhanced syslog API, that takes key-value pairs in addition to the traditional message, and outputs CEE-JSON to syslog. We also have (v)syslog() overrides, that do the same, just without the extra key-value pairs. Both of these add some extra stuff, via _cee_discover(): at the moment, this is the facility, the priority and the pid. We also override openlog(), that stores some info in thread-local storage. That info is used by _cee_discover(). For future use, this patch also defines LOG_CEE_NODISCOVER and LOG_CEE_NOCACHE. They're not used anywhere yet, though. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
* Lift out the JSON appender from _cee_vsyslog()Gergely Nagy2012-03-191-11/+31
| | | | | | | | I want to be able to modify the JSON from different functions, so that they can build on each other. For this to work, I need to be able to append to it, so I lifted it out into a separate function instead. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
* Remove the syslog() and vsyslog() overrides.Gergely Nagy2012-03-191-6/+0
| | | | | | | We will override syslog() and vsyslog() with other functions, remove the current aliases for now. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
* Lift out the formatting into a separate function.Gergely Nagy2012-03-191-13/+47
| | | | | | | | | | | | | | The formatting itself is now lifted out to _cee_vformat(), which returns a const char *, and puts the JSON object into its first (output) parameter. We then export cee_format() and cee_vformat(), that use this, strdup and return the result, and free the JSON object too. cee_vsyslog() was changed to use _cee_vformat(), because it does not need to strdup() the result. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
* Initial import.Gergely Nagy2012-03-191-0/+91