Tianjie Xu | e113e4d | 2016-10-21 17:46:13 -0700 | [diff] [blame] | 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 | |
Tao Bao | 245c522 | 2017-10-18 11:06:36 -0700 | [diff] [blame^] | 20 | #include <stddef.h> |
| 21 | #include <sys/types.h> |
Tianjie Xu | e113e4d | 2016-10-21 17:46:13 -0700 | [diff] [blame] | 22 | |
Tao Bao | 245c522 | 2017-10-18 11:06:36 -0700 | [diff] [blame^] | 23 | #include <log/log_id.h> |
Tianjie Xu | e113e4d | 2016-10-21 17:46:13 -0700 | [diff] [blame] | 24 | |
Tao Bao | 245c522 | 2017-10-18 11:06:36 -0700 | [diff] [blame^] | 25 | static constexpr int KEEP_LOG_COUNT = 10; |
Tianjie Xu | e113e4d | 2016-10-21 17:46:13 -0700 | [diff] [blame] | 26 | |
Tao Bao | 245c522 | 2017-10-18 11:06:36 -0700 | [diff] [blame^] | 27 | ssize_t logbasename(log_id_t id, char prio, const char* filename, const char* buf, size_t len, |
| 28 | void* arg); |
Tianjie Xu | e113e4d | 2016-10-21 17:46:13 -0700 | [diff] [blame] | 29 | |
Tao Bao | 245c522 | 2017-10-18 11:06:36 -0700 | [diff] [blame^] | 30 | ssize_t logrotate(log_id_t id, char prio, const char* filename, const char* buf, size_t len, |
| 31 | void* arg); |
Tianjie Xu | e113e4d | 2016-10-21 17:46:13 -0700 | [diff] [blame] | 32 | |
| 33 | // Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max. |
| 34 | // Similarly rename last_kmsg -> last_kmsg.1 -> ... -> last_kmsg.$max. |
| 35 | // Overwrite any existing last_log.$max and last_kmsg.$max. |
| 36 | void rotate_logs(const char* last_log_file, const char* last_kmsg_file); |
| 37 | |
| 38 | #endif //_ROTATE_LOG_H |