Commit Graph

32 Commits (9c15b9504ec4c7201376781234e5611215d120ee)

Author SHA1 Message Date
Peter Boström 9c15b9504e Fix clang -Wextra except -Wunused-parameter.
Cleared all warnings that occur when passing
CFLAGS="-Wall -Wextra -Wno-unused-parameter" to make using clang 3.3 on
Linux x86-64.
2014-01-02 22:15:33 +01:00
Jean-Philippe Ouellet 755188220f fix the build on OS X
OS X doesn't have posix_fallocate() yet, so put
bf760d0241 in
    #if defined(__APPLE__)

the cd fails with:
    /bin/sh: line 0: cd: include: No such file or directory
so give it a path relative to the top directory
2013-11-26 19:56:45 +01:00
Michael Stapelberg bf760d0241 log.c: use posix_fallocate() instead of ftruncate() (Thanks don)
The effect is that the error handling is much better. posix_fallocate()
will allocate all the requested space, whereas ftruncate() does not.

Before this commit, in case the /dev/shm filesystem is too small to hold
the _contents_ of the log file, i3 will SIGBUS when writing to the shm
logfile. With this commit, it will print an error message on startup,
but continue to run without logging.
2013-08-01 00:42:24 +02:00
Alexander Berntsen 023594909e Implement debuglog command
Add debuglog command that takes toggle|on|off. Add get_debug_logging()
to be able to toggle. Make t/187-commands-parser.t expect 'debuglog'.
Document the debuglog command in userguide.
2013-07-07 15:33:42 +02:00
Michael Stapelberg 85cb313153 reset shmlogname when disabling the log
This makes the i3-dump-log error message more helpful.
2013-06-23 22:14:39 +02:00
Alexander Berntsen f9d93d75b3 Implement shmlog command
Add shmlog command that takes <size>|toggle|on|off. Separate logbuffer
management into open_logbuffer() and close_logbuffer(). Make
t/187-commands-parser.t expect 'shmlog'. Add update_shmlog_atom() to
update the SHMLOG_PATH. Document the shmlog command in userguide.
2013-06-23 21:48:02 +02:00
Baptiste Daroussin 505d87ef3e FreeBSD expect a real path on the filesystem for shm_open 2013-03-20 17:29:06 +01:00
Baptiste Daroussin 346cba0e0f shm_unlink the created/open shm 2013-03-20 17:26:14 +01:00
Baptiste Daroussin f530e5452d Do not use ELOG while logwalk is not initialized 2013-03-20 17:24:10 +01:00
Michael Stapelberg 2eeb2a1067 shmlog: Remove O_TRUNC flag for shm_open, we truncate ourselves 2012-10-04 17:05:08 +02:00
Michael Stapelberg e68a8dd86c shm-logging: implement i3-dump-log -f (follow)
This changes the SHM log format, it doesn’t use 0-bytes to separate
entries anymore. Instead of using lots of printf() calls in i3-dump-log,
we now do precisely one big write().

So, to be clear: i3-dump-log and i3 both need to be upgraded.
Mismatching versions will lead to garbage output (no crashes of i3, just
garbage output).

The -f flag uses an inter-process pthread_cond_t in the shared memory
header to broadcast the arrival of new messages to all i3-dump-log
processes. This internally uses futexes and thus doesn’t even mean a
kernel call in most cases. inter-process pthread_cond_ts require NPTL
(the Native Posix Thread Library, introduce in Linux 2.6).
2012-08-13 01:06:09 +02:00
Michael Stapelberg 884627ef20 use I3__FILE__ for DLOG, leave __FILE__ as is
See also commit 0e752070ac, which broke
source code listings in gdb unless you cd into i3/src. This should give
us best of both :-).
2012-08-12 12:19:47 +02:00
Julius Plenz 70ec3867fe clean up zero-byte logfile on immediate exit
Otherwise, a zero-byte log file stays behind after every call to `i3
--get-socketpath`. Also, replace "return" calls with more explicit "exit"
calls.

Before:

$ ls -ld /tmp/i3* | wc -l; \
  repeat 10 i3 --get-socketpath >/dev/null; \
  ls -ld /tmp/i3* | wc -l
1
11

Now:

$ ls -ld /tmp/i3* | wc -l; \
  repeat 10 i3 --get-socketpath >/dev/null; \
  ls -ld /tmp/i3* | wc -l
1
1

Signed-off-by: Julius Plenz <julius@plenz.com>
2012-08-11 02:23:03 +02:00
Michael Stapelberg 0e752070ac explicitly set filenames to $(basename __FILE__)
This makes the debug log a bit more readable, especially since commit
48f1e383ca
2012-08-07 09:55:52 +02:00
Quentin Glidic bdc078914b i3: Replace loglevels by a global debug logging
File-limited were not used nor really useful
Besides, they are painful to maintain in Makefile rules compared to the
benefit
2012-07-22 18:41:12 +02:00
Michael Stapelberg 280a35717b log.c: len is always positive, remove useless check (Thanks Marcus) 2012-05-02 20:07:59 +02:00
Michael Stapelberg eedd1a64d7 Make log.c figure out the physical amount of memory on Mac OS X (Thanks Marcus) 2012-05-02 20:05:07 +02:00
Michael Stapelberg 206b96202c Use (void) instead of () for functions without args (Thanks fernandotcl)
See also:
http://article.gmane.org/gmane.linux.kernel/1268792

The C compiler will handle (void) as "no arguments" and () as "variadic
function" (equivalent to (...)) which might lead to subtle errors, such
as the one which was fixed with commit 0ea64ae4.
2012-03-31 10:53:04 +02:00
Michael Stapelberg dee7c07ad2 shmlog: store meta information in the buffer itself, store path as X11 atom
This makes i3-dump-log completely independent of a running i3 instance.
2012-01-06 23:40:07 +00:00
Michael Stapelberg 68544a519e Handle vsnprintf overflows (Thanks Han) 2011-12-30 01:26:36 +01:00
Michael Stapelberg f7a73f4a68 fix the SHM log size 2011-12-10 11:15:57 +00:00
Michael Stapelberg e65ee63763 Implement logging to a SHM ringbuffer
This feature is automatically enabled when running a debug version of i3.
The logfile will use 1% of your physical RAM size, but at max 25 MiB.
2011-12-10 10:50:33 +00:00
Michael Stapelberg 42d355f2b7 normalize modelines/headers across src/*.c 2011-10-22 23:40:02 +01:00
Michael Stapelberg f09d9a4c37 log: use localtime_r instead of localtime
localtime_r does not have the side-effect of behaving like it called tzset(),
in particular it will save one stat(/etc/localtime) syscall. This is not a big
deal, but it makes the strace output cleaner and thus more useful :).
2011-10-18 18:32:47 +01:00
Michael Walle 8adcf3e5d1 set close-on-exec flag on errorlogfile
Make sure the file descriptor is closed within the child after forking.

Signed-off-by: Michael Walle <michael@walle.cc>
2011-10-01 17:44:22 +01:00
Michael Stapelberg 22882f4e89 Bugfix: Initialize verbose to 'false' (Thanks tilman)
Verbosity was set to 'true' when we started the tree branch.
We forgot to set it back to 'false' :-).
2011-08-17 12:16:32 +02:00
Michael Stapelberg 48f5166daf log: display time in microseconds when DEBUG_TIMING is set 2011-07-10 23:11:21 +02:00
Michael Stapelberg c55abca115 add i3-nagbar. tells you about config file errors (for example) 2011-07-10 14:33:19 +02:00
Michael Stapelberg 5625a2f17f log.c: fix indenting 2010-11-29 22:28:23 +01:00
Michael Stapelberg 7f3a77ac6a loglevel bitmasks needs to be larger because we got more than 32 files 2010-04-17 17:46:11 +02:00
Michael Stapelberg c145f7e529 first step of the big refactoring ("tree" branch).
From here on, we can track changes. It made no sense to put the
development up to this point into git.
2010-04-13 13:17:39 +02:00
Michael Stapelberg 4226cc61de add log.c/log.h which contain all the log related macros and functions 2009-12-19 22:40:23 +01:00