]> mj.ucw.cz Git - libucw.git/blob - ucw/shell/logger.c
Set CONFIG_URL_ESCAPE_COMPAT flag
[libucw.git] / ucw / shell / logger.c
1 /*
2  *      UCW Library Utilities -- A Simple Logger for use in shell scripts
3  *
4  *      (c) 2001 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #include "ucw/lib.h"
11
12 #include <stdio.h>
13 #include <string.h>
14
15 int
16 main(int argc, char **argv)
17 {
18   byte buf[1024], *c;
19
20   log_init("logger");
21   if (argc < 3 || argc > 4 || strlen(argv[2]) != 1)
22     die("Usage: logger [<logname>:]<progname> <level> [<text>]");
23   if (c = strchr(argv[1], ':'))
24     {
25       *c++ = 0;
26       log_init(c);
27       log_file(argv[1]);
28     }
29   else
30     log_init(argv[1]);
31   if (argc > 3)
32     msg(argv[2][0], argv[3]);
33   else
34     while (fgets(buf, sizeof(buf), stdin))
35       {
36         c = strchr(buf, '\n');
37         if (c)
38           *c = 0;
39         msg(argv[2][0], buf);
40       }
41   return 0;
42 }