1 [[!meta title="Janovec Jiří"]]
4 **Project name and homepage:** [Busybox](http://busybox.net)
10 Add support -i option to command logger in busybox to log PID.
12 This can be done using [syslog](http://linux.die.net/man/3/syslog) man pages.
14 [BUG link](https://bugs.busybox.net/show_bug.cgi?id=8626)
18 3. ???send to developers
19 4. create presentation
27 Links documenting the results of my work
30 Here, I'll add links similar to the examples below and describe what
33 * [[Example] My communication with developers in a public mailing list archive](http://groups.google.com/group/comp.os.minix/browse_thread/thread/e3df794a2bce97da/2194d253268b0a1b?#2194d253268b0a1b)
34 * [[Example] Version control repository with the actual state of my work](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary)
35 * [[Example] My commit in the project repository](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ea90002b0fa7bdee86ec22eba1d951f30bf043a6)
36 * [[Example] Additional supporting material](http://lwn.net/Articles/385586/)
41 * [[Presentation of the aim of my work in PDF or OpenDocument format (upload it as an *Attachment* to this page)|prezentace1.pdf]]
42 * [[Presentation of the results of my work|prezentace2.pdf]]
47 Here, I'll fill in the HTML code of the [OpenHub widget][w] showing my KudoRank.
50 <a href='https://www.openhub.net/accounts/9897?ref=Detailed' target='_blank'>
51 <img alt='Ohloh profile for wentasah' border='0' height='35' src='https://www.openhub.net/accounts/9897/widgets/account_detailed.gif' width='230' />
54 [w]:https://www.openhub.net/accounts/janovji3/widgets
62 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
63 index b3ca857..58f9374 100644
64 --- a/sysklogd/logger.c
65 +++ b/sysklogd/logger.c
66 @@ -103,10 +103,12 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
67 str_t = uid2uname_utoa(geteuid());
69 /* Parse any options */
70 - opt = getopt32(argv, "p:st:", &str_p, &str_t);
71 + opt = getopt32(argv, "p:st:i", &str_p, &str_t);
73 if (opt & 0x2) /* -s */
75 + if (opt & 0x8) /* -i */
77 //if (opt & 0x4) /* -t */
79 i = LOG_USER | LOG_NOTICE;
84 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
85 index b3ca857..25b82cc 100644
86 --- a/sysklogd/logger.c
87 +++ b/sysklogd/logger.c
89 //config: messages to the system log (i.e. the 'syslogd' utility) so
90 //config: they can be logged. This is generally used to help locate
91 //config: problems that occur within programs and scripts.
93 +//config:config FEATURE_LOG_PID
94 +//config: bool "Log PID of logger"
96 +//config: depends on LOGGER
98 +//config: This enables logger to log process id (PID).
100 //applet:IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))
103 //usage: "[OPTIONS] [MESSAGE]"
104 //usage:#define logger_full_usage "\n\n"
105 //usage: "Write MESSAGE (or stdin) to syslog\n"
106 +//usage: IF_FEATURE_LOG_PID(
107 +//usage: "\n -i Log the process ID too"
109 //usage: "\n -s Log to stderr as well as the system log"
110 //usage: "\n -t TAG Log using the specified tag (defaults to user name)"
111 //usage: "\n -p PRIO Priority (numeric or facility.level pair)"
118 + OPTBIT_priority = 0, // -p
119 + OPTBIT_stderr, // -s
121 + IF_FEATURE_LOG_PID(OPTBIT_pid ,) // -i
123 + OPT_priority = 1 << OPTBIT_priority ,
124 + OPT_stderr = 1 << OPTBIT_stderr ,
125 + OPT_tag = 1 << OPTBIT_tag ,
126 + OPT_pid = IF_FEATURE_LOG_PID((1 << OPTBIT_pid )) + 0,
128 +#define OPTION_STR "p:st:" \
129 + IF_FEATURE_LOG_PID("i:" )
130 +#define OPTION_DECL *str_p, *str_t
131 +#define OPTION_PARAM &str_p, &str_t
133 /* Decode a symbolic name to a numeric value
134 * this function is based on code
135 * Copyright (c) 1983, 1993
136 @@ -95,7 +122,7 @@ static int pencode(char *s)
137 int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
138 int logger_main(int argc UNUSED_PARAM, char **argv)
140 - char *str_p, *str_t;
145 @@ -103,14 +130,19 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
146 str_t = uid2uname_utoa(geteuid());
148 /* Parse any options */
149 - opt = getopt32(argv, "p:st:", &str_p, &str_t);
150 + opt = getopt32(argv, OPTION_STR, OPTION_PARAM);
151 +getopt32(argv, "p:st:i", &str_p, &str_t);
153 - if (opt & 0x2) /* -s */
154 + if (opt & OPT_stderr) /* -s */
156 - //if (opt & 0x4) /* -t */
157 +#if ENABLE_FEATURE_LOG_PID
158 + if (opt & OPT_pid) /* -i */
161 + //if (opt & OPT_tag) /* -t */
162 openlog(str_t, i, 0);
163 i = LOG_USER | LOG_NOTICE;
164 - if (opt & 0x1) /* -p */
165 + if (opt & OPT_priority) /* -p */