aboutsummaryrefslogtreecommitdiff
path: root/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/log_do.c
blob: 01e8e01fe92cc4c1efa78b2111226d0919bcf3b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include "time_defs.h"

void log_do(char *buf,int OK, char *program, char *username, char *tty) /*EXTRACT_INCL*/{
  char *p=buf;
  *p++ ='<'; 
  p += fmt_ulong(p, (10<<3) | (4+2*OK));  /* 4 warn, 5 notice, 6 info */
  *p++ = '>';
  nv_ctime(p,time(0), 26);
  p += str_add(p,p+4,16);
  p += str_add(p,program,32);  *p++='[';
  p += fmt_ulong(p,getpid());
  p += str_copy(p,"]: ");
  p += str_add(p,username,32);
  p += str_copy(p, (OK) ? " logged on " : " fail on ");
  p += str_add(p,tty,32);
  *p++ = '\n';
  write_devlog(buf, p-buf);
}