blob: 0d64c6082c6257175f579823ee3a280d4ca8b4f8 [file] [log] [blame]
Elliott Hughes42ee1422011-09-06 12:33:32 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
Elliott Hugheseb4f6142011-07-15 17:43:51 -070016
17#include "logging.h"
18
19#include <iostream>
20#include <unistd.h>
21
22#include "cutils/log.h"
23
24static const int kLogSeverityToAndroidLogPriority[] = {
25 ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL
26};
27
28LogMessage::LogMessage(const char* file, int line, LogSeverity severity, int error)
Elliott Hughes42ee1422011-09-06 12:33:32 -070029: file_(file), line_number_(line), severity_(severity), errno_(error)
Elliott Hugheseb4f6142011-07-15 17:43:51 -070030{
31}
32
Elliott Hughes42ee1422011-09-06 12:33:32 -070033void LogMessage::LogLine(const char* line) {
Elliott Hugheseb4f6142011-07-15 17:43:51 -070034 int priority = kLogSeverityToAndroidLogPriority[severity_];
Elliott Hughes42ee1422011-09-06 12:33:32 -070035 LOG_PRI(priority, LOG_TAG, "%s", line);
Elliott Hugheseb4f6142011-07-15 17:43:51 -070036}