aboutsummaryrefslogtreecommitdiffstats
path: root/src/loglevel.c
blob: de2a4e111446ca5ee34128087b2a4a94a54b422e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

/* Change the default console loglevel */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/unistd.h>
#include <sys/syscall.h>

int main(int argc, char **argv) {
   int level;

   if (!argv[1]) exit(0);
   level=atoi(argv[1]);
   if ( (level<1) || (level>8) ) {
      fprintf(stderr,"invalid log level %d\n",level);
      exit(-1);
   }
   if (!syscall(SYS_syslog,8,NULL,level)) {
      exit(0);
   } else {
      perror("syslog");
      exit(-1);
   }
}