Home | History | Annotate | Download | only in cutils
      1 /* utils/logger.h
      2 **
      3 ** Copyright 2007, The Android Open Source Project
      4 **
      5 ** This file is dual licensed.  It may be redistributed and/or modified
      6 ** under the terms of the Apache 2.0 License OR version 2 of the GNU
      7 ** General Public License.
      8 */
      9 
     10 #ifndef _UTILS_LOGGER_H
     11 #define _UTILS_LOGGER_H
     12 
     13 #include <stdint.h>
     14 
     15 /*
     16  * The userspace structure for version 1 of the logger_entry ABI.
     17  * This structure is returned to userspace by the kernel logger
     18  * driver unless an upgrade to a newer ABI version is requested.
     19  */
     20 struct logger_entry {
     21     uint16_t    len;    /* length of the payload */
     22     uint16_t    __pad;  /* no matter what, we get 2 bytes of padding */
     23     int32_t     pid;    /* generating process's pid */
     24     int32_t     tid;    /* generating process's tid */
     25     int32_t     sec;    /* seconds since Epoch */
     26     int32_t     nsec;   /* nanoseconds */
     27     char        msg[0]; /* the entry's payload */
     28 };
     29 
     30 /*
     31  * The userspace structure for version 2 of the logger_entry ABI.
     32  * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION)
     33  * is called with version==2
     34  */
     35 struct logger_entry_v2 {
     36     uint16_t    len;       /* length of the payload */
     37     uint16_t    hdr_size;  /* sizeof(struct logger_entry_v2) */
     38     int32_t     pid;       /* generating process's pid */
     39     int32_t     tid;       /* generating process's tid */
     40     int32_t     sec;       /* seconds since Epoch */
     41     int32_t     nsec;      /* nanoseconds */
     42     uint32_t    euid;      /* effective UID of logger */
     43     char        msg[0];    /* the entry's payload */
     44 };
     45 
     46 #define LOGGER_LOG_MAIN		"log/main"
     47 #define LOGGER_LOG_RADIO	"log/radio"
     48 #define LOGGER_LOG_EVENTS	"log/events"
     49 #define LOGGER_LOG_SYSTEM	"log/system"
     50 
     51 /*
     52  * The maximum size of the log entry payload that can be
     53  * written to the kernel logger driver. An attempt to write
     54  * more than this amount to /dev/log/* will result in a
     55  * truncated log entry.
     56  */
     57 #define LOGGER_ENTRY_MAX_PAYLOAD	4076
     58 
     59 /*
     60  * The maximum size of a log entry which can be read from the
     61  * kernel logger driver. An attempt to read less than this amount
     62  * may result in read() returning EINVAL.
     63  */
     64 #define LOGGER_ENTRY_MAX_LEN		(5*1024)
     65 
     66 #ifdef HAVE_IOCTL
     67 
     68 #include <sys/ioctl.h>
     69 
     70 #define __LOGGERIO	0xAE
     71 
     72 #define LOGGER_GET_LOG_BUF_SIZE		_IO(__LOGGERIO, 1) /* size of log */
     73 #define LOGGER_GET_LOG_LEN		_IO(__LOGGERIO, 2) /* used log len */
     74 #define LOGGER_GET_NEXT_ENTRY_LEN	_IO(__LOGGERIO, 3) /* next entry len */
     75 #define LOGGER_FLUSH_LOG		_IO(__LOGGERIO, 4) /* flush log */
     76 #define LOGGER_GET_VERSION		_IO(__LOGGERIO, 5) /* abi version */
     77 #define LOGGER_SET_VERSION		_IO(__LOGGERIO, 6) /* abi version */
     78 
     79 #endif // HAVE_IOCTL
     80 
     81 #endif /* _UTILS_LOGGER_H */
     82