      SUBROUTINE PLW.LOG(FNAME,R.ERR,R.LEN)
*PIC-LAN
*
*ALL
*PC
*Y
*
*
*
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      DIM DD(3)
*
      IF FNAME[1,5] = '/RPC/' THEN RETURN
*
      F1 = INDEX(PLIP$WWW.LOG.OPT,'F',1)
      F2 = INDEX(PLIP$WWW.LOG.OPT,'I',1)
*
      PL_GET_HDR XX FROM 'X-CONNADDR' THEN
         L.IP = FIELD(XX,' ',1)
         R.IP = FIELD(XX,' ',2)
      END ELSE
         L.IP = ST$IP
         R.IP = ST$RIP
      END
*
      IF F1 OR F2 THEN
         D = PL_DATE()
         D<2> = PL_TIME()
         D<3> = L.IP
         D<4> = R.IP
         D<5> = FNAME
         D<6> = R.ERR
         D<7> = R.LEN
*
         IF F1 THEN
            PL_READU ID FROM PL$CTRL.FD , 'LOG.ID' ELSE ID = 1
            WRITE ( ID + 1 ) ON PL$CTRL.FD , 'LOG.ID'
            WRITE D ON PL$LOG.FD , ID 'R%8'
*
            PL_READVU D FROM PL$LOGFNAME.FD , FNAME , 1 ELSE D = ''
            D = D + 1
            WRITEV D ON PL$LOGFNAME.FD , FNAME , 1
         END
*
         IF F2 THEN
            PL_READVU D FROM PL$LOGIP.FD , FIELD(R.IP,':',1) , 1 ELSE D = ''
            D = D + 1
            WRITEV D ON PL$LOGIP.FD , FIELD(R.IP,':',1) , 1
         END
      END
*
RETURN
      IF INDEX(PLIP$WWW.LOG.OPT,'B',1) THEN
         DT = INT( PL_NOW() / 86400 )
         TM = MOD( PL_NOW() , 86400 )
         H = INT( TM / 3600 ) 'R%2'
         M = INT( MOD( TM , 3600 ) / 60 ) 'R%2'
         S = MOD( TM , 60 ) 'R%2'
*
         ID = DT : '*' : H : ':' : M
         N = INT(S/10) + 1
*
         PL_MATREADU DD FROM PL$LOGUSAGE.FD , ID ELSE MAT DD = ''
         DD(1)<1,N> = DD(1)<1,N> + R.LEN
         DD(2)<1,N> = DD(2)<1,N> + 1
         MATWRITE DD ON PL$LOGUSAGE.FD , ID
*
         ID = DT : '*' : H
         N = M + 1
*
         PL_MATREADU DD FROM PL$LOGUSAGE.FD , ID ELSE MAT DD = ''
         DD(1)<1,N> = DD(1)<1,N> + R.LEN
         DD(2)<1,N> = DD(2)<1,N> + 1
         MATWRITE DD ON PL$LOGUSAGE.FD , ID
*
         ID = DT
         N = H + 1
*
         PL_MATREADU DD FROM PL$LOGUSAGE.FD, ID ELSE MAT DD = ''
         DD(1)<1,N> = DD(1)<1,N> + R.LEN
         DD(2)<1,N> = DD(2)<1,N> + 1
         MATWRITE DD ON PL$LOGUSAGE.FD , ID
      END
*
      RETURN
   END
