18f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin/*
28f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * Copyright (C) 2010 The Android Open Source Project
38f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin *
48f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * Licensed under the Apache License, Version 2.0 (the "License");
58f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * you may not use this file except in compliance with the License.
68f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * You may obtain a copy of the License at
78f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin *
88f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin *      http://www.apache.org/licenses/LICENSE-2.0
98f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin *
108f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * Unless required by applicable law or agreed to in writing, software
118f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * distributed under the License is distributed on an "AS IS" BASIS,
128f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * See the License for the specific language governing permissions and
148f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin * limitations under the License.
158f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin */
168f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin
178f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#ifndef _CUTILS_KLOG_H_
188f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define _CUTILS_KLOG_H_
198f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin
207425fd1b231fcdb3c260877a13f794a0c7361e80Ken Sumrall#include <sys/cdefs.h>
217425fd1b231fcdb3c260877a13f794a0c7361e80Ken Sumrall
227425fd1b231fcdb3c260877a13f794a0c7361e80Ken Sumrall__BEGIN_DECLS
237425fd1b231fcdb3c260877a13f794a0c7361e80Ken Sumrall
248f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavinvoid klog_init(void);
258f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavinvoid klog_set_level(int level);
268f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavinvoid klog_close(void);
278f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavinvoid klog_write(int level, const char *fmt, ...)
288f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin    __attribute__ ((format(printf, 2, 3)));
298f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin
307425fd1b231fcdb3c260877a13f794a0c7361e80Ken Sumrall__END_DECLS
317425fd1b231fcdb3c260877a13f794a0c7361e80Ken Sumrall
328f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define KLOG_ERROR(tag,x...)   klog_write(3, "<3>" tag ": " x)
338f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define KLOG_WARNING(tag,x...) klog_write(4, "<4>" tag ": " x)
348f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define KLOG_NOTICE(tag,x...)  klog_write(5, "<5>" tag ": " x)
358f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define KLOG_INFO(tag,x...)    klog_write(6, "<6>" tag ": " x)
368f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define KLOG_DEBUG(tag,x...)   klog_write(7, "<7>" tag ": " x)
378f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin
388f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#define KLOG_DEFAULT_LEVEL  3  /* messages <= this level are logged */
398f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin
408f91282ebe1963b9d27f8779ad1342302b293bd2Dima Zavin#endif
41