1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* utils/logger.h
2dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project**
3dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** Copyright 2007, The Android Open Source Project
4dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project**
5dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** This file is dual licensed.  It may be redistributed and/or modified
6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** under the terms of the Apache 2.0 License OR version 2 of the GNU
7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** General Public License.
8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project*/
9dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
10dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifndef _UTILS_LOGGER_H
11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define _UTILS_LOGGER_H
12dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
13dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <stdint.h>
14dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
156756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich/*
166756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * The userspace structure for version 1 of the logger_entry ABI.
176756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * This structure is returned to userspace by the kernel logger
186756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * driver unless an upgrade to a newer ABI version is requested.
196756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich */
20dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectstruct logger_entry {
21dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    uint16_t    len;    /* length of the payload */
22dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    uint16_t    __pad;  /* no matter what, we get 2 bytes of padding */
23dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    int32_t     pid;    /* generating process's pid */
24dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    int32_t     tid;    /* generating process's tid */
25dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    int32_t     sec;    /* seconds since Epoch */
26dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    int32_t     nsec;   /* nanoseconds */
27dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    char        msg[0]; /* the entry's payload */
28dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project};
29dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
306756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich/*
316756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * The userspace structure for version 2 of the logger_entry ABI.
326756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION)
336756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * is called with version==2
346756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich */
356756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevichstruct logger_entry_v2 {
366756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    uint16_t    len;       /* length of the payload */
376756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    uint16_t    hdr_size;  /* sizeof(struct logger_entry_v2) */
386756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    int32_t     pid;       /* generating process's pid */
396756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    int32_t     tid;       /* generating process's tid */
406756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    int32_t     sec;       /* seconds since Epoch */
416756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    int32_t     nsec;      /* nanoseconds */
426756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    uint32_t    euid;      /* effective UID of logger */
436756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich    char        msg[0];    /* the entry's payload */
446756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich};
456756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich
46dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_LOG_MAIN		"log/main"
47dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_LOG_RADIO	"log/radio"
48dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_LOG_EVENTS	"log/events"
49e2bf2ea4d2846031edfc52b942ad53e5467243f6Joe Onorato#define LOGGER_LOG_SYSTEM	"log/system"
50dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
516756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich/*
526756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * The maximum size of the log entry payload that can be
536756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * written to the kernel logger driver. An attempt to write
546756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * more than this amount to /dev/log/* will result in a
556756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * truncated log entry.
566756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich */
576756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich#define LOGGER_ENTRY_MAX_PAYLOAD	4076
586756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich
596756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich/*
606756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * The maximum size of a log entry which can be read from the
616756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * kernel logger driver. An attempt to read less than this amount
626756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich * may result in read() returning EINVAL.
636756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich */
646756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich#define LOGGER_ENTRY_MAX_LEN		(5*1024)
65dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
66dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifdef HAVE_IOCTL
67dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <sys/ioctl.h>
69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
70dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define __LOGGERIO	0xAE
71dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
72dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_GET_LOG_BUF_SIZE		_IO(__LOGGERIO, 1) /* size of log */
73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_GET_LOG_LEN		_IO(__LOGGERIO, 2) /* used log len */
74dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_GET_NEXT_ENTRY_LEN	_IO(__LOGGERIO, 3) /* next entry len */
75dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define LOGGER_FLUSH_LOG		_IO(__LOGGERIO, 4) /* flush log */
766756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich#define LOGGER_GET_VERSION		_IO(__LOGGERIO, 5) /* abi version */
776756a0c9fe930cc5ccebf5313f605df0d127a2dbNick Kralevich#define LOGGER_SET_VERSION		_IO(__LOGGERIO, 6) /* abi version */
78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
79dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif // HAVE_IOCTL
80dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
81dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif /* _UTILS_LOGGER_H */
82