blob: ccb0cac3526dd14ddc945a2be66d2727c2bad4b6 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/* 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>
Nick Kralevich56c30652012-02-21 15:48:53 -080014#include <sys/types.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080015
Nick Kralevich56c30652012-02-21 15:48:53 -080016/*
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 */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080021struct 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
Nick Kralevich56c30652012-02-21 15:48:53 -080031/*
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
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080047#define LOGGER_LOG_MAIN "log/main"
48#define LOGGER_LOG_RADIO "log/radio"
49#define LOGGER_LOG_EVENTS "log/events"
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -080050#define LOGGER_LOG_SYSTEM "log/system"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080051
Nick Kralevich56c30652012-02-21 15:48:53 -080052/*
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)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080066
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 */
Nick Kralevich56c30652012-02-21 15:48:53 -080077#define LOGGER_GET_VERSION _IO(__LOGGERIO, 5) /* abi version */
78#define LOGGER_SET_VERSION _IO(__LOGGERIO, 6) /* abi version */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080079
80#endif // HAVE_IOCTL
81
82#endif /* _UTILS_LOGGER_H */