diff options
author | Tianjie Xu | 2016-10-21 19:46:13 -0500 |
---|---|---|
committer | Tianjie Xu | 2016-11-03 20:16:33 -0500 |
commit | e113e4d67fb581e7232ffe8c430b8bf4f44e08bb (patch) | |
tree | 4344cb07a28fb6ff2454d3efa672dc6bd5797a56 /rotate_logs.h | |
parent | 4011bb161a60fb04fb0d4c4c3e1090d43fcdd9e4 (diff) | |
download | platform-bootable-recovery-e113e4d67fb581e7232ffe8c430b8bf4f44e08bb.tar.gz platform-bootable-recovery-e113e4d67fb581e7232ffe8c430b8bf4f44e08bb.tar.xz platform-bootable-recovery-e113e4d67fb581e7232ffe8c430b8bf4f44e08bb.zip |
Cleanup the duplicates of logs rotation functions
Bug: 32067516
Test: Logs rotated successfully on angler, recovery-refresh/persist tests
passed on an a/b device.
Change-Id: Ie80adf0fa958ad3d7869d2d17f49489666b86c29
Diffstat (limited to 'rotate_logs.h')
-rw-r--r-- | rotate_logs.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/rotate_logs.h b/rotate_logs.h new file mode 100644 index 00000000..809c213b --- /dev/null +++ b/rotate_logs.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _ROTATE_LOGS_H | ||
18 | #define _ROTATE_LOGS_H | ||
19 | |||
20 | #include <string> | ||
21 | |||
22 | #include <private/android_logger.h> /* private pmsg functions */ | ||
23 | |||
24 | constexpr int KEEP_LOG_COUNT = 10; | ||
25 | |||
26 | ssize_t logbasename(log_id_t /* logId */, | ||
27 | char /* prio */, | ||
28 | const char *filename, | ||
29 | const char * /* buf */, size_t len, | ||
30 | void *arg); | ||
31 | |||
32 | ssize_t logrotate( | ||
33 | log_id_t logId, | ||
34 | char prio, | ||
35 | const char *filename, | ||
36 | const char *buf, size_t len, | ||
37 | void *arg); | ||
38 | |||
39 | // Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max. | ||
40 | // Similarly rename last_kmsg -> last_kmsg.1 -> ... -> last_kmsg.$max. | ||
41 | // Overwrite any existing last_log.$max and last_kmsg.$max. | ||
42 | void rotate_logs(const char* last_log_file, const char* last_kmsg_file); | ||
43 | |||
44 | #endif //_ROTATE_LOG_H | ||