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