am 6260fa50
: am ee9da565
: am 58522099
: Merge "Make logging fall back to /dev/stderr if we\'re on the host."
* commit '6260fa5025fa4173700a6db70a244748acc5388a': Make logging fall back to /dev/stderr if we're on the host.
This commit is contained in:
commit
d57fbcbb0f
@ -419,9 +419,34 @@ int __libc_format_fd(int fd, const char* format, ...) {
|
|||||||
return os.total;
|
return os.total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __libc_write_stderr(const char* tag, const char* msg) {
|
||||||
|
int fd = TEMP_FAILURE_RETRY(open("/dev/stderr", O_CLOEXEC | O_WRONLY));
|
||||||
|
if (fd == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
iovec vec[4];
|
||||||
|
vec[0].iov_base = const_cast<char*>(tag);
|
||||||
|
vec[0].iov_len = strlen(tag);
|
||||||
|
vec[1].iov_base = const_cast<char*>(": ");
|
||||||
|
vec[1].iov_len = 2;
|
||||||
|
vec[2].iov_base = const_cast<char*>(msg);
|
||||||
|
vec[2].iov_len = strlen(msg) + 1;
|
||||||
|
vec[3].iov_base = const_cast<char*>("\n");
|
||||||
|
vec[3].iov_len = 1;
|
||||||
|
|
||||||
|
int result = TEMP_FAILURE_RETRY(writev(fd, vec, 4));
|
||||||
|
close(fd);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static int __libc_write_log(int priority, const char* tag, const char* msg) {
|
static int __libc_write_log(int priority, const char* tag, const char* msg) {
|
||||||
int main_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/main", O_CLOEXEC | O_WRONLY));
|
int main_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/main", O_CLOEXEC | O_WRONLY));
|
||||||
if (main_log_fd == -1) {
|
if (main_log_fd == -1) {
|
||||||
|
if (errno == ENOTDIR) {
|
||||||
|
// /dev/log isn't a directory? Maybe we're running on the host? Try stderr instead.
|
||||||
|
return __libc_write_stderr(tag, msg);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
#ifndef _LINKER_DEBUG_H_
|
#ifndef _LINKER_DEBUG_H_
|
||||||
#define _LINKER_DEBUG_H_
|
#define _LINKER_DEBUG_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// You can increase the verbosity of debug traces by defining the LD_DEBUG
|
// You can increase the verbosity of debug traces by defining the LD_DEBUG
|
||||||
// environment variable to a numeric value from 0 to 2 (corresponding to
|
// environment variable to a numeric value from 0 to 2 (corresponding to
|
||||||
// INFO, TRACE, and DEBUG calls in the source). This will only
|
// INFO, TRACE, and DEBUG calls in the source). This will only
|
||||||
@ -55,9 +53,6 @@
|
|||||||
* To enable/disable specific debug options, change the defines above
|
* To enable/disable specific debug options, change the defines above
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
|
||||||
|
|
||||||
#include "private/libc_logging.h"
|
#include "private/libc_logging.h"
|
||||||
|
|
||||||
__LIBC_HIDDEN__ extern int gLdDebugVerbosity;
|
__LIBC_HIDDEN__ extern int gLdDebugVerbosity;
|
||||||
|
Loading…
Reference in New Issue
Block a user