[launchd-changes] [22865] trunk/launchd/src/launchd_runtime.c
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 21 12:37:43 PDT 2006
Revision: 22865
http://trac.macosforge.org/projects/launchd/changeset/22865
Author: zarzycki at apple.com
Date: 2006-09-21 12:37:43 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
This code is Disabled with an #if 0 statement. I'd rather not delete it because it may come in handy again.
Modified Paths:
--------------
trunk/launchd/src/launchd_runtime.c
Modified: trunk/launchd/src/launchd_runtime.c
===================================================================
--- trunk/launchd/src/launchd_runtime.c 2006-09-21 19:19:35 UTC (rev 22864)
+++ trunk/launchd/src/launchd_runtime.c 2006-09-21 19:37:43 UTC (rev 22865)
@@ -572,3 +572,87 @@
}
}
}
+
+#if 0
+
+/* For ugly debug scenarios where syslogd is long gone (for example, during system shutdown). */
+
+void
+closelog(void)
+{
+}
+
+void
+openlog(const char *ident, int logopt, int facility)
+{
+ ident = 0;
+ logopt = 0;
+ facility = 0;
+}
+
+int
+setlogmask(int maskpri)
+{
+ return maskpri;
+}
+
+void
+syslog(int priority, const char *message, ...)
+{
+ va_list ap;
+
+ va_start(ap, message);
+
+ vsyslog(priority, message, ap);
+
+ va_end(ap);
+}
+
+void
+vsyslog(int priority, const char *message, va_list args)
+{
+ static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER;
+ static FILE *ourlogfile = NULL;
+ int saved_errno = errno;
+ char newmsg[10000];
+ size_t i, j;
+
+ pthread_mutex_lock(&ourlock);
+
+ if (ourlogfile == NULL) {
+ ourlogfile = fopen("/var/log/launchd_raw.log", "a");
+ }
+
+ pthread_mutex_unlock(&ourlock);
+
+ if (ourlogfile == NULL) {
+ return;
+ }
+
+ if (message == NULL) {
+ return;
+ }
+
+ sprintf(newmsg, "p%u pp%u\t", getpid(), getppid());
+
+ for (i = 0, j = strlen(newmsg); message[i];) {
+ if (message[i] == '%' && message[i + 1] == 'm') {
+ char *errs = strerror(saved_errno);
+ strcpy(newmsg + j, errs ? errs : "unknown error");
+ j += strlen(newmsg + j);
+ i += 2;
+ } else {
+ newmsg[j] = message[i];
+ j++;
+ i++;
+ }
+ }
+
+ strcpy(newmsg + j, "\n");
+
+ vfprintf(ourlogfile, newmsg, args);
+
+ fflush(ourlogfile);
+}
+
+#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20060921/dbd18c68/attachment.html
More information about the launchd-changes
mailing list