3 * Copyright (c) 2005-2008, The Android Open Source Project
4 * Copyright (c) 2012-2020 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include <queued_entry.h>
25 /* Logfile rotation */
26 #define DEFAULT_ROTATE_SIZE_KB 1024
27 #define DEFAULT_ROTATE_NUM_FILES 3
29 #define BtoKiB(x) ((x) >> 10)
38 size_t rotate_size_kbytes;
40 struct log_format format;
43 int32_t prev_sec; /* previously written entry's timestamp, seconds */
44 int32_t prev_nsec; /* previously written timestamp, nanoseconds */
51 void logfile_init(struct log_file *l_file);
52 void logfile_move(struct log_file *to, struct log_file *from);
53 void logfile_free(struct log_file *l_file);
54 void logfile_set_fd(struct log_file *l_file, int fd, int should_close);
55 int logfile_set_path(struct log_file *l_file, const char *path);
56 int logfile_open(struct log_file *l_file);
57 int logfile_rotate_needed(struct log_file *l_file);
58 void logfile_do_rotate(struct log_file *file);
59 int logfile_write_with_rotation(const dlogutil_entry_s *e, struct log_file *file, dlogutil_sorting_order_e sort_by);
65 #endif /* _LOG_FILE_H */