CUPS page logging (page_log) broken with backend hp

Bug #485994 reported by martin_jacobs
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned

Bug Description

I've CUPS 1.3.11 and HPLIP 3.9.10 installed and running.

One motivation to switch from LPRnG to CUPS was it's built in accounting, especially page logging. Now I found out that my page_log file remains empty, although all print queues are regularily installed using current ppd files provided by HPLIP.

After some investigation I learned that page logging is triggered by PAGE: <num> <num> messages written by filter chain to stderr and then processed by cupsd. Furthermore last filter in chain is hpcups and hpcups does not write such DEBUG messages. Is that something that can be configured during compile time? Or is this issue already on HPLIP's road map?

What I found out so far is this:

- We've to look at whole process chains built out-of multiple filters and one backend process.
- hplip uses hp as backend
- hplip writes PAGE: 1 1 if and only if file descriptor fd is not zero (hp.c):

      if (fd != 0)
      {
         fputs("PAGE: 1 1\n", stderr);
         lseek(fd, 0, SEEK_SET);
      }

- hplip sets fd to zero if argc equals 6 (hp.c)
   if (argc == 6)
   {
      fd = 0; /* use stdin. */
      copies = 1;
   }
That means backend hp does not write PAGE: messages to cupsd if operating in normal cups environment.

- cups' job.c sets argv[6] to NULL after first filter process is started. That makes sense because argv[6] is a pointer to print job source file and only first filter needs to know about that. All other processes build a filter chain reading from stdin and writing to stdout. It's cupsd's task to connect processes and pipes the right way.

taken from job.c of cups 1.3.11, lines 3382ff
   cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Started filter %s (PID %d)",
                    job->id, command, pid);

    argv[6] = NULL;
    slot = !slot;
  }
This looks the same in job.c taken from 1.4.2 ( * "$Id: job.c 8801 2009-08-29 06:05:14Z mike $" )

IMHO backend hp is not compatible with current cups implementation.

Suggestion: move fputs(...) in front of if (fd != 0) { ... }:

      fputs("PAGE: 1 1\n", stderr);
      if (fd != 0)
      {
         /* start reading from beginning of given file */
         lseek(fd, 0, SEEK_SET);
      }

With this change in file prnt/backend/hp.c compiled and installed I got my very first page_log entry today:

litfass mjacobs 521 [20/Nov/2009:19:47:35 +0100] 1 1 - localhost

BR / Martin

Revision history for this message
martin_jacobs (martin-jacobs) wrote :

This is a patch against prnt/backend/hp.c as described in my bug report.

Revision history for this message
martin_jacobs (martin-jacobs) wrote :

Unfortunately this is not a complete fix because it reports only one page per copy. I'll do more investigation on this issue.

Revision history for this message
Shakil (shakilk-deactivatedaccount) wrote :

Thanks Martin, for working on this issue and helping HPLIP. Do let us know your final patch once ready so that we can test against it.

Regards
Shakil
======

Revision history for this message
Giovanni Mascellani (giomasce) wrote :

Any news on this issue? It's probably hitting me too. :-(

Revision history for this message
martin_jacobs (martin-jacobs) wrote :

No, unfortunately not. Current situation for me is:
CUPS 1.4.8, HPLIP 3.11.7
CUPS does write page log entries to file configured in cupsd.conf line
PageLog /var/log/cups/page_log
My patch of backend file hp.c seems to be obsolete. I'll double check that and post results.

Revision history for this message
martin_jacobs (martin-jacobs) wrote :

As promised:

1. My patch is basically obsolete.

2. Any complain about page accounting has to take into account, that CUPS page accounting does only work under certain conditions. A brief description is given here http://www.cups.org/documentation.php/doc-1.4/accounting.html

What does that mean for CPUS/HPLIP? Print jobs using print devices of HPLIP send page accounting information (HPCupsFilter.cpp, line 643). At least if printing raw data you won't get page accounting information.

Revision history for this message
Namo Amitabha (namo-amitabha) wrote :

Ubuntu 16.04 uses HPLIP 3.16.3, whose "hp" backend still does not write any page_log. Verified it in the hplip 3.16.3 source code (prnt/backend/hp.c). So Martin's patch does not seem obsolete :-). Thanks to and based on Martin's explanation and patch, I improved it a bit, so it writes the proper page number and number of copies to STDERR, and thus to page_log. Tested with multiple HP LaserJet M225dw and M401dne printers. Any one interested in the patch?

Revision history for this message
Paul Casteels (pcasteels) wrote :

For me page_log also remains empty with hplip-3.18.6 and CUPS 2.1.3.
Here (https://lists.cups.org/pipermail/cups/2016-May/056088.html) I found the suggestion to simply comment out the hpps driver from the ppd file:
%*cupsFilter: "application/vnd.cups-postscript 0 hpps"
This seems to work.
Is there any reason to try to get hpps working and where can I find a patched version?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.