]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Drop remainder of ASL logging code since it is deprecated in macOS Sierra.
authorMichael R Sweet <michaelrsweet@gmail.com>
Thu, 20 Oct 2016 20:45:51 +0000 (16:45 -0400)
committerMichael R Sweet <michaelrsweet@gmail.com>
Thu, 20 Oct 2016 20:45:51 +0000 (16:45 -0400)
scheduler/conf.c
scheduler/log.c
scheduler/main.c

index 8110cb475c1a639c6f991161e5adb933b2c98971..ab271087ab39fb0a360d95f986f5a28841b5af47 100644 (file)
@@ -276,20 +276,11 @@ cupsdCheckPermissions(
                          "Unable to create directory \"%s\" - %s", filename,
                          strerror(errno));
         else
-#ifdef HAVE_ASL_H
-        {
-         asl_object_t  m;              /* Log message */
-
-         m = asl_new(ASL_TYPE_MSG);
-         asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-         asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to create directory \"%s\" - %s", filename, strerror(errno));
-         asl_release(m);
-       }
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
          sd_journal_print(LOG_ERR, "Unable to create directory \"%s\" - %s", filename, strerror(errno));
 #else
          syslog(LOG_ERR, "Unable to create directory \"%s\" - %s", filename, strerror(errno));
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
         return (-1);
       }
@@ -326,20 +317,11 @@ cupsdCheckPermissions(
     if (create_dir >= 0)
       cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a directory.", filename);
     else
-#ifdef HAVE_ASL_H
-    {
-      asl_object_t     m;              /* Log message */
-
-      m = asl_new(ASL_TYPE_MSG);
-      asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-      asl_log(NULL, m, ASL_LEVEL_ERR, "\"%s\" is not a directory.", filename);
-      asl_release(m);
-    }
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
       sd_journal_print(LOG_ERR, "\"%s\" is not a directory.", filename);
 #else
       syslog(LOG_ERR, "\"%s\" is not a directory.", filename);
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
     return (-1);
   }
@@ -368,20 +350,11 @@ cupsdCheckPermissions(
                        "Unable to change ownership of \"%s\" - %s", filename,
                        strerror(errno));
       else
-#ifdef HAVE_ASL_H
-      {
-       asl_object_t    m;              /* Log message */
-
-       m = asl_new(ASL_TYPE_MSG);
-       asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-       asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to change ownership of \"%s\" - %s", filename, strerror(errno));
-       asl_release(m);
-      }
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
        sd_journal_print(LOG_ERR, "Unable to change ownership of \"%s\" - %s", filename, strerror(errno));
 #else
        syslog(LOG_ERR, "Unable to change ownership of \"%s\" - %s", filename, strerror(errno));
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
       return (1);
     }
@@ -400,20 +373,11 @@ cupsdCheckPermissions(
                        "Unable to change permissions of \"%s\" - %s", filename,
                        strerror(errno));
       else
-#ifdef HAVE_ASL_H
-      {
-       asl_object_t    m;              /* Log message */
-
-       m = asl_new(ASL_TYPE_MSG);
-       asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-       asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to change permissions of \"%s\" - %s", filename, strerror(errno));
-       asl_release(m);
-      }
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
        sd_journal_print(LOG_ERR, "Unable to change permissions of \"%s\" - %s", filename, strerror(errno));
 #else
        syslog(LOG_ERR, "Unable to change permissions of \"%s\" - %s", filename, strerror(errno));
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
       return (1);
     }
@@ -839,20 +803,11 @@ cupsdReadConfiguration(void)
       if (TestConfigFile)
         printf("\"%s\" contains errors.\n", CupsFilesFile);
       else
-#ifdef HAVE_ASL_H
-      {
-       asl_object_t    m;              /* Log message */
-
-       m = asl_new(ASL_TYPE_MSG);
-       asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-       asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to read \"%s\" due to errors.", CupsFilesFile);
-       asl_release(m);
-      }
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
        sd_journal_print(LOG_ERR, "Unable to read \"%s\" due to errors.", CupsFilesFile);
 #else
         syslog(LOG_LPR, "Unable to read \"%s\" due to errors.", CupsFilesFile);
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
       return (0);
     }
@@ -861,19 +816,11 @@ cupsdReadConfiguration(void)
     cupsdLogMessage(CUPSD_LOG_INFO, "No %s, using defaults.", CupsFilesFile);
   else
   {
-#ifdef HAVE_ASL_H
-    asl_object_t       m;              /* Log message */
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-    asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to open \"%s\" - %s", CupsFilesFile, strerror(errno));
-    asl_release(m);
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
     sd_journal_print(LOG_ERR, "Unable to open \"%s\" - %s", CupsFilesFile, strerror(errno));
 #else
     syslog(LOG_LPR, "Unable to open \"%s\" - %s", CupsFilesFile, strerror(errno));
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
     return (0);
   }
@@ -887,18 +834,11 @@ cupsdReadConfiguration(void)
 
   if ((fp = cupsFileOpen(ConfigurationFile, "r")) == NULL)
   {
-#ifdef HAVE_ASL_H
-    asl_object_t       m;              /* Log message */
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-    asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to open \"%s\" - %s", ConfigurationFile, strerror(errno));
-    asl_release(m);
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
     sd_journal_print(LOG_ERR, "Unable to open \"%s\" - %s", ConfigurationFile, strerror(errno));
 #else
     syslog(LOG_LPR, "Unable to open \"%s\" - %s", ConfigurationFile, strerror(errno));
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
     return (0);
   }
@@ -912,20 +852,11 @@ cupsdReadConfiguration(void)
     if (TestConfigFile)
       printf("\"%s\" contains errors.\n", ConfigurationFile);
     else
-#ifdef HAVE_ASL_H
-    {
-      asl_object_t     m;              /* Log message */
-
-      m = asl_new(ASL_TYPE_MSG);
-      asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-      asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to read \"%s\" due to errors.", ConfigurationFile);
-      asl_release(m);
-    }
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
       sd_journal_print(LOG_ERR, "Unable to read \"%s\" due to errors.", ConfigurationFile);
 #else
       syslog(LOG_LPR, "Unable to read \"%s\" due to errors.", ConfigurationFile);
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
     return (0);
   }
index 0a135a7a286086fc288a3a1bbf51742defe5c23d..69b5b3b89787e4f744bc7adee7a79d53469e8e99 100644 (file)
@@ -225,20 +225,11 @@ cupsdCheckLogFile(cups_file_t **lf,       /* IO - Log file */
 
       if (*lf == NULL)
       {
-#ifdef HAVE_ASL_H
-       asl_object_t    m;              /* Log message */
-
-       m = asl_new(ASL_TYPE_MSG);
-       asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-       asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
-       asl_release(m);
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
         sd_journal_print(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
-
 #else
        syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
         if (FatalErrors & CUPSD_FATAL_LOG)
          cupsdEndProcess(getpid(), 0);
@@ -279,20 +270,12 @@ cupsdCheckLogFile(cups_file_t **lf,       /* IO - Log file */
 
     if ((*lf = cupsFileOpen(filename, "a")) == NULL)
     {
-#ifdef HAVE_ASL_H
-       asl_object_t    m;              /* Log message */
-
-       m = asl_new(ASL_TYPE_MSG);
-       asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-       asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
-       asl_release(m);
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
-        sd_journal_print(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
+      sd_journal_print(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
 
 #else
-       syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
-#endif /* HAVE_ASL_H */
+      syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno));
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
       if (FatalErrors & CUPSD_FATAL_LOG)
        cupsdEndProcess(getpid(), 0);
@@ -585,52 +568,7 @@ cupsdLogJob(cupsd_job_t *job,              /* I - Job */
   if (level > LogLevel && LogDebugHistory <= 0)
     return (1);
 
-#ifdef HAVE_ASL_H
-  if (!strcmp(ErrorLog, "syslog"))
-  {
-    asl_object_t       m;              /* Log message */
-    char               job_id[32],     /* job-id string */
-                       completed[32];  /* job-impressions-completed string */
-    cupsd_printer_t *printer = job ? (job->printer ? job->printer : (job->dest ? cupsdFindDest(job->dest) : NULL)) : NULL;
-    static const char * const job_states[] =
-    {                                  /* job-state strings */
-      "Pending",
-      "PendingHeld",
-      "Processing",
-      "ProcessingStopped",
-      "Canceled",
-      "Aborted",
-      "Completed"
-    };
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-    if (printer)
-      asl_set(m, PWG_ServiceURI, printer->uri);
-    if (job)
-    {
-      snprintf(job_id, sizeof(job_id), "%d", job->id);
-
-      asl_set(m, PWG_Event, "JobStateChanged");
-      asl_set(m, PWG_JobID, job_id);
-      asl_set(m, PWG_JobState, job->state_value < IPP_JSTATE_PENDING ? "" : job_states[job->state_value - IPP_JSTATE_PENDING]);
-
-      if (job->impressions)
-      {
-       snprintf(completed, sizeof(completed), "%d", ippGetInteger(job->impressions, 0));
-       asl_set(m, PWG_JobImpressionsCompleted, completed);
-      }
-    }
-
-    va_start(ap, message);
-    asl_vlog(NULL, m, log_levels[level], message, ap);
-    va_end(ap);
-
-    asl_release(m);
-    return (1);
-  }
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
   if (!strcmp(ErrorLog, "syslog"))
   {
     cupsd_printer_t *printer = job ? (job->printer ? job->printer : (job->dest ? cupsdFindDest(job->dest) : NULL)) : NULL;
@@ -673,7 +611,7 @@ cupsdLogJob(cupsd_job_t *job,               /* I - Job */
 
     return (1);
   }
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
  /*
   * Format and write the log message...
@@ -769,15 +707,7 @@ cupsdLogMessage(int        level,  /* I - Log level */
   {
     va_start(ap, message);
 
-#ifdef HAVE_ASL_H
-    asl_object_t       m;              /* Log message */
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-    asl_vlog(NULL, m, log_levels[level], message, ap);
-    asl_release(m);
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
     sd_journal_printv(log_levels[level], message, ap);
 
 #elif defined(HAVE_VSYSLOG)
@@ -786,7 +716,7 @@ cupsdLogMessage(int        level,   /* I - Log level */
 #else
     vfprintf(stderr, message, ap);
     putc('\n', stderr);
-#endif /* HAVE_VSYSLOG */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
     va_end(ap);
 
@@ -796,23 +726,7 @@ cupsdLogMessage(int        level,  /* I - Log level */
   if (level > LogLevel || !ErrorLog)
     return (1);
 
-#ifdef HAVE_ASL_H
-  if (!strcmp(ErrorLog, "syslog"))
-  {
-    asl_object_t       m;              /* Log message */
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-
-    va_start(ap, message);
-    asl_vlog(NULL, m, log_levels[level], message, ap);
-    va_end(ap);
-
-    asl_release(m);
-    return (1);
-  }
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
   if (!strcmp(ErrorLog, "syslog"))
   {
     va_start(ap, message);
@@ -820,7 +734,7 @@ cupsdLogMessage(int        level,   /* I - Log level */
     va_end(ap);
     return (1);
   }
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
  /*
   * Format and write the log message...
@@ -1035,45 +949,7 @@ cupsdLogPage(cupsd_job_t *job,            /* I - Job being printed */
 
   *bufptr = '\0';
 
-#ifdef HAVE_ASL_H
-  if (!strcmp(ErrorLog, "syslog"))
-  {
-    asl_object_t       m;              /* Log message */
-    char               job_id[32],     /* job-id string */
-                       completed[32];  /* job-impressions-completed string */
-    static const char * const job_states[] =
-    {                                  /* job-state strings */
-      "Pending",
-      "PendingHeld",
-      "Processing",
-      "ProcessingStopped",
-      "Canceled",
-      "Aborted",
-      "Completed"
-    };
-
-    snprintf(job_id, sizeof(job_id), "%d", job->id);
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-    asl_set(m, PWG_Event, "JobStateChanged");
-    asl_set(m, PWG_ServiceURI, job->printer->uri);
-    asl_set(m, PWG_JobID, job_id);
-    asl_set(m, PWG_JobState, job_states[job->state_value - IPP_JSTATE_PENDING]);
-
-    if (job->impressions)
-    {
-      snprintf(completed, sizeof(completed), "%d", ippGetInteger(job->impressions, 0));
-      asl_set(m, PWG_JobImpressionsCompleted, completed);
-    }
-
-    asl_log(NULL, m, ASL_LEVEL_INFO, "%s", buffer);
-
-    asl_release(m);
-    return (1);
-  }
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
   if (!strcmp(ErrorLog, "syslog"))
   {
     static const char * const job_states[] =
@@ -1109,7 +985,7 @@ cupsdLogPage(cupsd_job_t *job,             /* I - Job being printed */
 
     return (1);
   }
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
  /*
   * Not using syslog; check the log file...
@@ -1270,29 +1146,7 @@ cupsdLogRequest(cupsd_client_t *con,     /* I - Request to log */
     }
   }
 
-#ifdef HAVE_ASL_H
-  if (!strcmp(ErrorLog, "syslog"))
-  {
-    asl_object_t       m;              /* Log message */
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-
-    asl_log(NULL, m, ASL_LEVEL_INFO, "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n",
-           con->http->hostname, con->username[0] != '\0' ? con->username : "-",
-          states[con->operation], _httpEncodeURI(temp, con->uri, sizeof(temp)),
-          con->http->version / 100, con->http->version % 100,
-          code, CUPS_LLCAST con->bytes,
-          con->request ?
-              ippOpString(con->request->request.op.operation_id) : "-",
-          con->response ?
-              ippErrorString(con->response->request.status.status_code) : "-");
-
-    asl_release(m);
-    return (1);
-  }
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
   if (!strcmp(ErrorLog, "syslog"))
   {
     sd_journal_print(LOG_INFO, "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s", con->http->hostname, con->username[0] != '\0' ? con->username : "-", states[con->operation], _httpEncodeURI(temp, con->uri, sizeof(temp)), con->http->version / 100, con->http->version % 100, code, CUPS_LLCAST con->bytes, con->request ? ippOpString(con->request->request.op.operation_id) : "-", con->response ? ippErrorString(con->response->request.status.status_code) : "-");
@@ -1319,7 +1173,7 @@ cupsdLogRequest(cupsd_client_t *con,      /* I - Request to log */
 
     return (1);
   }
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
  /*
   * Not using syslog; check the log file...
@@ -1377,20 +1231,7 @@ cupsdWriteErrorLog(int        level,     /* I - Log level */
                };
 
 
-#ifdef HAVE_ASL_H
-  if (!strcmp(ErrorLog, "syslog"))
-  {
-    asl_object_t       m;              /* Log message */
-
-    m = asl_new(ASL_TYPE_MSG);
-    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-    asl_log(NULL, m, ASL_LEVEL_INFO, "%s", message);
-
-    asl_release(m);
-    return (1);
-  }
-
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
   if (!strcmp(ErrorLog, "syslog"))
   {
     sd_journal_print(log_levels[level], "%s", message);
@@ -1407,7 +1248,7 @@ cupsdWriteErrorLog(int        level,      /* I - Log level */
     syslog(log_levels[level], "%s", message);
     return (1);
   }
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
  /*
   * Not using syslog; check the log file...
index 0dcd32de0e2588160716056f06f67c579726b072..e18ffb0c68106cba7df060f9b549447bd8f49973 100644 (file)
@@ -765,18 +765,11 @@ main(int  argc,                           /* I - Number of command-line args */
 
         if (!cupsdReadConfiguration())
         {
-#ifdef HAVE_ASL_H
-         asl_object_t  m;              /* Log message */
-
-         m = asl_new(ASL_TYPE_MSG);
-         asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
-         asl_log(NULL, m, ASL_LEVEL_ERR, "Unable to read configuration file \"%s\" - exiting.", ConfigurationFile);
-         asl_release(m);
-#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
          sd_journal_print(LOG_ERR, "Unable to read configuration file \"%s\" - exiting.", ConfigurationFile);
 #else
           syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting.", ConfigurationFile);
-#endif /* HAVE_ASL_H */
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
 
           break;
        }