Move init to libbase logging.
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 452e333..d64c3d2 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -71,12 +71,12 @@
static int insmod(const char *filename, const char *options, int flags) {
int fd = open(filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
- ERROR("insmod: open(\"%s\") failed: %s", filename, strerror(errno));
+ PLOG(ERROR) << "insmod: open(\"" << filename << "\") failed";
return -1;
}
int rc = syscall(__NR_finit_module, fd, options, flags);
if (rc == -1) {
- ERROR("finit_module for \"%s\" failed: %s", filename, strerror(errno));
+ PLOG(ERROR) << "finit_module for \"" << filename << "\" failed";
}
close(fd);
return rc;
@@ -201,13 +201,13 @@
const char *f2fs_argv[] = {
"/system/bin/fsck.f2fs", "-f", entry->mnt_fsname,
};
- android_fork_execvp_ext(ARRAY_SIZE(f2fs_argv), (char **)f2fs_argv,
+ android_fork_execvp_ext(arraysize(f2fs_argv), (char **)f2fs_argv,
&st, true, LOG_KLOG, true, NULL, NULL, 0);
} else if (!strcmp(entry->mnt_type, "ext4")) {
const char *ext4_argv[] = {
"/system/bin/e2fsck", "-f", "-y", entry->mnt_fsname,
};
- android_fork_execvp_ext(ARRAY_SIZE(ext4_argv), (char **)ext4_argv,
+ android_fork_execvp_ext(arraysize(ext4_argv), (char **)ext4_argv,
&st, true, LOG_KLOG, true, NULL, NULL, 0);
}
}
@@ -421,7 +421,7 @@
}
close(fd);
- ERROR("out of loopback devices");
+ LOG(ERROR) << "out of loopback devices";
return -1;
} else {
if (wait)
@@ -445,7 +445,7 @@
write(fd, "--reason=wipe_data_via_recovery\n", strlen("--reason=wipe_data_via_recovery\n") + 1);
close(fd);
} else {
- ERROR("could not open /cache/recovery/command\n");
+ PLOG(ERROR) << "could not open /cache/recovery/command";
return -1;
}
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
@@ -499,9 +499,9 @@
if (pid > 0) {
/* Parent. Wait for the child to return */
int wp_ret = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0));
- if (wp_ret < 0) {
- /* Unexpected error code. We will continue anyway. */
- NOTICE("waitpid failed rc=%d: %s\n", wp_ret, strerror(errno));
+ if (wp_ret == -1) {
+ // Unexpected error code. We will continue anyway.
+ PLOG(WARNING) << "waitpid failed";
}
if (WIFEXITED(status)) {
@@ -516,7 +516,7 @@
child_ret = fs_mgr_mount_all(fstab);
fs_mgr_free_fstab(fstab);
if (child_ret == -1) {
- ERROR("fs_mgr_mount_all returned an error\n");
+ PLOG(ERROR) << "fs_mgr_mount_all returned an error";
}
_exit(child_ret);
} else {
@@ -541,7 +541,7 @@
ActionManager::GetInstance().QueueEventTrigger("nonencrypted");
} else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) {
/* Setup a wipe via recovery, and reboot into recovery */
- ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n");
+ PLOG(ERROR) << "fs_mgr_mount_all suggested recovery, so wiping data via recovery.";
ret = wipe_data_via_recovery();
/* If reboot worked, there is no return. */
} else if (ret == FS_MGR_MNTALL_DEV_DEFAULT_FILE_ENCRYPTED) {
@@ -562,7 +562,7 @@
property_set("ro.crypto.type", "file");
property_set("vold.decrypt", "trigger_restart_min_framework");
} else if (ret > 0) {
- ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret);
+ PLOG(ERROR) << "fs_mgr_mount_all returned unexpected error " << ret;
}
/* else ... < 0: error */
@@ -599,7 +599,7 @@
static int do_start(const std::vector<std::string>& args) {
Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]);
if (!svc) {
- ERROR("do_start: Service %s not found\n", args[1].c_str());
+ LOG(ERROR) << "do_start: Service " << args[1] << " not found";
return -1;
}
if (!svc->Start())
@@ -610,7 +610,7 @@
static int do_stop(const std::vector<std::string>& args) {
Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]);
if (!svc) {
- ERROR("do_stop: Service %s not found\n", args[1].c_str());
+ LOG(ERROR) << "do_stop: Service " << args[1] << " not found";
return -1;
}
svc->Stop();
@@ -620,7 +620,7 @@
static int do_restart(const std::vector<std::string>& args) {
Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]);
if (!svc) {
- ERROR("do_restart: Service %s not found\n", args[1].c_str());
+ LOG(ERROR) << "do_restart: Service " << args[1] << " not found";
return -1;
}
svc->Restart();
@@ -641,7 +641,7 @@
cmd = ANDROID_RB_RESTART2;
len = 6;
} else {
- ERROR("powerctl: unrecognized command '%s'\n", command);
+ LOG(ERROR) << "powerctl: unrecognized command '" << command << "'";
return -EINVAL;
}
@@ -655,7 +655,7 @@
reboot_target = &command[len + 1];
}
} else if (command[len] != '\0') {
- ERROR("powerctl: unrecognized reboot target '%s'\n", &command[len]);
+ LOG(ERROR) << "powerctl: unrecognized reboot target '" << &command[len] << "'";
return -EINVAL;
}
@@ -692,7 +692,7 @@
// Wait a bit before recounting the number or running services.
usleep(kTerminateServiceDelayMicroSeconds);
}
- NOTICE("Terminating running services took %.02f seconds", t.duration());
+ LOG(VERBOSE) << "Terminating running services took " << t.duration() << " seconds";
}
return android_reboot_with_callback(cmd, 0, reboot_target,
@@ -868,7 +868,7 @@
static int do_loglevel(const std::vector<std::string>& args) {
int log_level = std::stoi(args[1]);
if (log_level < KLOG_ERROR_LEVEL || log_level > KLOG_DEBUG_LEVEL) {
- ERROR("loglevel: invalid log level'%d'\n", log_level);
+ LOG(ERROR) << "loglevel: invalid log level " << log_level;
return -EINVAL;
}
klog_set_level(log_level);