3 * Copyright (c) 2005-2008, The Android Open Source Project
4 * Copyright (c) 2012-2013 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.
45 typedef struct log_format_t log_format;
47 typedef struct log_entry_t {
50 log_priority priority;
58 log_format *log_format_new();
60 void log_format_free(log_format *p_format);
62 void log_set_print_format(log_format *p_format,
63 log_print_format format);
66 * Returns FORMAT_OFF on invalid string
68 log_print_format log_format_from_string(const char *s);
71 * filterExpression: a single filter expression
74 * returns 0 on success and -1 on invalid expression
76 * Assumes single threaded execution
80 int log_add_filter_rule(log_format *p_format,
81 const char *filterExpression);
85 * filterString: a whitespace-separated set of filter expressions
88 * returns 0 on success and -1 on invalid expression
90 * Assumes single threaded execution
94 int log_add_filter_string(log_format *p_format,
95 const char *filterString);
99 * returns 1 if this log line should be printed based on its priority
100 * and tag, and 0 if it should not
102 int log_should_print_line (
103 log_format *p_format, const char *tag, log_priority pri);
107 * Splits a wire-format buffer into an log_entry
108 * entry allocated by caller. Pointers will point directly into buf
110 * Returns 0 on success and -1 on invalid wire format (entry will be
111 * in unspecified state)
113 int log_process_log_buffer(struct logger_entry *buf,
117 * Formats a log message into a buffer
119 * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
120 * If return value != defaultBuffer, caller must call free()
121 * Returns NULL on malloc error
124 char *log_format_log_line (
125 log_format *p_format,
127 size_t defaultBufferSize,
128 const log_entry *p_line,
129 size_t *p_outLength);
133 * Either print or do not print log line, based on filter
135 * Assumes single threaded execution
138 int log_print_log_line(
139 log_format *p_format,
141 const log_entry *entry);
144 * logprint test furction
147 void logprint_run_tests(void);
153 #endif /*_LOGPRINT_H*/