2
* Copyright (C) 2008 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.
17
// All static variables go here, to control initialization and
18
// destruction order in the library.
20
#include <private/utils/Static.h>
22
#include <utils/BufferedTextOutput.h>
23
#include <utils/Log.h>
27
class LibUtilsFirstStatics
30
LibUtilsFirstStatics()
33
initialize_string16();
36
~LibUtilsFirstStatics()
43
static LibUtilsFirstStatics gFirstStatics;
44
int gDarwinCantLoadAllObjects = 1;
46
// ------------ Text output streams
48
Vector<int32_t> gTextBuffers;
50
class LogTextOutput : public BufferedTextOutput
53
LogTextOutput() : BufferedTextOutput(MULTITHREADED) { }
54
virtual ~LogTextOutput() { };
57
virtual status_t writeLines(const struct iovec& vec, size_t N)
59
//android_writevLog(&vec, N); <-- this is now a no-op
60
if (N != 1) ALOGI("WARNING: writeLines N=%zu\n", N);
61
ALOGI("%.*s", (int)vec.iov_len, (const char*) vec.iov_base);
66
class FdTextOutput : public BufferedTextOutput
69
FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
70
virtual ~FdTextOutput() { };
73
virtual status_t writeLines(const struct iovec& vec, size_t N)
83
static LogTextOutput gLogTextOutput;
84
static FdTextOutput gStdoutTextOutput(STDOUT_FILENO);
85
static FdTextOutput gStderrTextOutput(STDERR_FILENO);
87
TextOutput& alog(gLogTextOutput);
88
TextOutput& aout(gStdoutTextOutput);
89
TextOutput& aerr(gStderrTextOutput);
91
} // namespace android