2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
42 typedef struct log_format_t log_format;
44 typedef struct log_entry_t {
47 log_priority priority;
55 log_format *log_format_new();
57 void log_format_free(log_format *p_format);
59 void log_set_print_format(log_format *p_format,
60 log_print_format format);
63 * Returns FORMAT_OFF on invalid string
65 log_print_format log_format_from_string(const char *s);
68 * filterExpression: a single filter expression
71 * returns 0 on success and -1 on invalid expression
73 * Assumes single threaded execution
77 int log_add_filter_rule(log_format *p_format,
78 const char *filterExpression);
82 * filterString: a whitespace-separated set of filter expressions
85 * returns 0 on success and -1 on invalid expression
87 * Assumes single threaded execution
91 int log_add_filter_string(log_format *p_format,
92 const char *filterString);
96 * returns 1 if this log line should be printed based on its priority
97 * and tag, and 0 if it should not
99 int log_should_print_line (
100 log_format *p_format, const char *tag, log_priority pri);
104 * Splits a wire-format buffer into an log_entry
105 * entry allocated by caller. Pointers will point directly into buf
107 * Returns 0 on success and -1 on invalid wire format (entry will be
108 * in unspecified state)
110 int log_process_log_buffer(struct logger_entry *buf,
114 * Formats a log message into a buffer
116 * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
117 * If return value != defaultBuffer, caller must call free()
118 * Returns NULL on malloc error
121 char *log_format_log_line (
122 log_format *p_format,
124 size_t defaultBufferSize,
125 const log_entry *p_line,
126 size_t *p_outLength);
130 * Either print or do not print log line, based on filter
132 * Assumes single threaded execution
135 int log_print_log_line(
136 log_format *p_format,
138 const log_entry *entry);
146 #endif /*_LOGPRINT_H*/