3 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is furnished
10 * to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 #include <logcommon.h>
31 #include <ptrs_list.h>
32 #include <queued_entry.h>
55 log_print_format format;
59 struct log_write_buffer {
63 struct timespec oldest_log;
65 struct log_filter *log_filter_new();
67 void log_filter_free(struct log_filter *p_filter);
70 log_priority global_pri;
71 bool exact_global_pri;
72 bool need_apply_default;
75 void log_filter_init(struct log_filter *p_filter);
77 struct log_write_buffer log_write_buffer_new();
79 void log_write_buffer_free(struct log_write_buffer *buf);
82 * Returns a deep copy of the passed object.
84 struct log_filter *log_filter_from_filter(const struct log_filter *p_filter);
86 struct log_filter *log_filter_move(struct log_filter *p_filter);
89 * Returns FORMAT_OFF on invalid string
91 log_print_format log_format_from_string(const char *s);
94 * filterExpression: a single filter expression
97 * returns 0 on success and -1 on invalid expression
99 * Assumes single threaded execution
103 int log_add_filter_rule(struct log_filter *p_filter, const char *filterExpression);
105 void log_filter_clear(struct log_filter *p_filter);
107 struct tag_and_prio {
115 typedef struct FilterInfo_t {
122 struct tag_and_prio tnp;
128 list_head log_filter_get_list(struct log_filter *p_filter);
130 log_priority log_filter_get_global_priority(struct log_filter *p_filter, bool *is_exact);
132 int log_filter_set_filterspec(struct log_filter *p_filter,
133 const char *filterString);
134 int log_filter_set_pid(struct log_filter *p_filter, pid_t pid);
135 int log_filter_set_tid(struct log_filter *p_filter, pid_t tid);
137 bool log_filter_need_apply_default(struct log_filter *p_filter);
140 * returns true if this log line should be printed based on its entry
141 * data (priority, tag, pid and tid), and false if it should not
143 bool log_should_print_line(
144 struct log_filter *p_filter, const dlogutil_entry_s *entry);
147 * Formats a log message into a buffer
149 * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
150 * If return value != defaultBuffer, caller must call free()
151 * Returns NULL on malloc error
154 char *log_format_log_line(
155 const struct log_format p_format,
157 size_t defaultBufferSize,
158 const dlogutil_entry_s *p_line,
159 size_t *p_outLength);
162 * Either print or do not print log line, based on filter
164 * Assumes single threaded execution
167 int log_print_log_line(
168 struct log_format p_format,
170 const dlogutil_entry_s *entry,
171 struct log_write_buffer *buf);
173 dlogutil_sorting_order_e get_format_sorting(log_print_format format);
179 #endif /*_LOGPRINT_H*/