X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fshell%2Flogger.c;h=4cb76876a35aee818e5716c0e9ac592bdea066d6;hb=05ffab94be8da943cffb8fb30d7073ab78aef94c;hp=8d67abec5c09ff15d1e5737f344e277110c9016c;hpb=a4fe009d3366b0a3e119713b0ecc7fc0070efdfa;p=libucw.git diff --git a/ucw/shell/logger.c b/ucw/shell/logger.c index 8d67abec..4cb76876 100644 --- a/ucw/shell/logger.c +++ b/ucw/shell/logger.c @@ -1,13 +1,14 @@ /* * UCW Library Utilities -- A Simple Logger for use in shell scripts * - * (c) 2001 Martin Mares + * (c) 2001--2009 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" +#include +#include #include #include @@ -28,15 +29,22 @@ main(int argc, char **argv) } else log_init(argv[1]); + + uns level = 0; + while (level < L_MAX && LS_LEVEL_LETTER(level) != argv[2][0]) + level++; + if (level >= L_MAX) + die("Unknown logging level `%s'", argv[2]); + if (argc > 3) - msg(argv[2][0], argv[3]); + msg(level, argv[3]); else while (fgets(buf, sizeof(buf), stdin)) { c = strchr(buf, '\n'); if (c) *c = 0; - msg(argv[2][0], buf); + msg(level, buf); } return 0; }