Skip to content

Commit

Permalink
make logging work better
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Mar 18, 2024
1 parent e12b609 commit 5f035fd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
23 changes: 17 additions & 6 deletions include/payload/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,28 @@ void NSLog(CFStringRef, ...);

extern os_log_t palera1nd_log;

enum { // Legal level values for CFLog()
kCFLogLevelEmergency = 0,
kCFLogLevelAlert = 1,
kCFLogLevelCritical = 2,
kCFLogLevelError = 3,
kCFLogLevelWarning = 4,
kCFLogLevelNotice = 5,
kCFLogLevelInfo = 6,
kCFLogLevelDebug = 7,
};
CF_EXPORT void CFLog(int32_t level, CFStringRef format, ...);

#ifdef DEV_BUILD
#define PALERA1ND_LOG_DEBUG(...) os_log(palera1nd_log, __VA_ARGS__)
#define PALERA1ND_LOG_DEBUG(a, ...) CFLog(kCFLogLevelNotice, CFSTR(a), ##__VA_ARGS__)
#else
#define PALERA1ND_LOG_DEBUG(...)
#define PALERA1ND_LOG_DEBUG(a, ...)
#endif

#define PALERA1ND_LOG_ERROR(...) os_log(palera1nd_log, __VA_ARGS__)
#define PALERA1ND_LOG_FAULT(...) os_log(palera1nd_log, __VA_ARGS__)
#define PALERA1ND_LOG_INFO(...) os_log(palera1nd_log, __VA_ARGS__)
#define PALERA1ND_LOG(...) os_log(palera1nd_log, __VA_ARGS__)
#define PALERA1ND_LOG_ERROR(a, ...) CFLog(kCFLogLevelNotice, CFSTR(a), ##__VA_ARGS__)
#define PALERA1ND_LOG_FAULT(a, ...) CFLog(kCFLogLevelNotice, CFSTR(a), ##__VA_ARGS__)
#define PALERA1ND_LOG_INFO(a, ...) CFLog(kCFLogLevelNotice, CFSTR(a), ##__VA_ARGS__)
#define PALERA1ND_LOG(a, ...) CFLog(kCFLogLevelNotice, CFSTR(a), ##__VA_ARGS__)

typedef int launchctl_cmd_main(xpc_object_t *msg, int argc, char **argv, char **envp, char **apple);
launchctl_cmd_main bootstrap_cmd;
Expand Down
2 changes: 1 addition & 1 deletion src/payload/jailbreakd/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void* write_log(void* arg) {

while ((didRead = read(fd, buf, 0x1000)) != -1) {
if (didRead > 0) {
PALERA1ND_LOG("%{public}s: %{public}s", ((struct nslog_stderr_info*)arg)->desc, buf);
PALERA1ND_LOG("%s: %s", ((struct nslog_stderr_info*)arg)->desc, buf);
memset(buf, 0, 0x1000);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/payload/jailbreakd/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define RB2_USERREBOOT (0x2000000000000000llu)

#ifdef HAVE_DEBUG_JBD_MSG
#define STR_FORMAT "%{public}s"
#define STR_FORMAT "%s"
#else
#define STR_FORMAT "%s"
#endif
Expand Down Expand Up @@ -66,7 +66,7 @@ void palera1nd_handler(xpc_object_t peer, xpc_object_t request, struct paleinfo*
SecTaskRef task = SecTaskCreateWithAuditToken(kCFAllocatorDefault, token);
if (task) {
CFStringRef signingIdentifier = SecTaskCopySigningIdentifier(task, NULL);
PALERA1ND_LOG("received dictionary from client %{public}@(%d): " STR_FORMAT, signingIdentifier ? signingIdentifier : CFSTR("unknown"), pid, xrequeststr);
PALERA1ND_LOG("received dictionary from client %@(%d): " STR_FORMAT, signingIdentifier ? signingIdentifier : CFSTR("unknown"), pid, xrequeststr);
if (signingIdentifier) CFRelease(signingIdentifier);
if (task) CFRelease(task);
}
Expand Down

0 comments on commit 5f035fd

Please sign in to comment.