Change default redbean log level to info

A new -s flag has been added to increase silence. This change is
intended to make it a little less weird opening the redbean binary
directly from the browser and seeing an empty terminal window.
This commit is contained in:
Justine Tunney 2021-05-01 05:28:15 -07:00
parent 1966369e8e
commit 41801c9802

View file

@ -430,7 +430,8 @@ DESCRIPTION\n\
FLAGS\n\ FLAGS\n\
\n\ \n\
-h help\n\ -h help\n\
-v verbosity [repeat]\n\ -s increase silence [repeat]\n\
-v increase verbosity [repeat]\n\
-d daemonize\n\ -d daemonize\n\
-u uniprocess\n\ -u uniprocess\n\
-z print port\n\ -z print port\n\
@ -444,7 +445,7 @@ FLAGS\n\
" -H K:V sets http header globally [repeat]\n\ " -H K:V sets http header globally [repeat]\n\
-D DIR serve assets from local directory [repeat]\n\ -D DIR serve assets from local directory [repeat]\n\
-t MS tunes read and write timeouts [default 30000]\n\ -t MS tunes read and write timeouts [default 30000]\n\
-M INT tune max message payload size [default 65536]\n\ -M INT tunes max message payload size [default 65536]\n\
-c SEC configures static asset cache-control headers\n\ -c SEC configures static asset cache-control headers\n\
-r /X=/Y redirect X to Y [repeat]\n\ -r /X=/Y redirect X to Y [repeat]\n\
-R /X=/Y rewrites X to Y [repeat]\n\ -R /X=/Y rewrites X to Y [repeat]\n\
@ -949,7 +950,7 @@ static void SetDefaults(void) {
#else #else
ProgramBrand("redbean/0.4"); ProgramBrand("redbean/0.4");
#endif #endif
__log_level = kLogWarn; __log_level = kLogInfo;
maxpayloadsize = 64 * 1024; maxpayloadsize = 64 * 1024;
ProgramCache(-1); ProgramCache(-1);
ProgramTimeout(30 * 1000); ProgramTimeout(30 * 1000);
@ -1021,12 +1022,15 @@ static void ProgramHeader(const char *s) {
static void GetOpts(int argc, char *argv[]) { static void GetOpts(int argc, char *argv[]) {
int opt; int opt;
while ((opt = getopt(argc, argv, "azhdugvmbfl:p:r:R:H:c:L:P:U:G:B:D:t:M:")) != while ((opt = getopt(argc, argv,
-1) { "azhdugvsmbfl:p:r:R:H:c:L:P:U:G:B:D:t:M:")) != -1) {
switch (opt) { switch (opt) {
case 'v': case 'v':
__log_level++; __log_level++;
break; break;
case 's':
__log_level--;
break;
case 'd': case 'd':
daemonize = true; daemonize = true;
break; break;
@ -4544,7 +4548,10 @@ void RedBean(int argc, char *argv[], const char *prog) {
CHECK_NE(-1, listen(server, 10)); CHECK_NE(-1, listen(server, 10));
addrsize = sizeof(serveraddr); addrsize = sizeof(serveraddr);
CHECK_NE(-1, getsockname(server, &serveraddr, &addrsize)); CHECK_NE(-1, getsockname(server, &serveraddr, &addrsize));
VERBOSEF("LISTEN %s", DescribeServer()); struct in_addr addr = serveraddr.sin_addr;
if (addr.s_addr == INADDR_ANY) addr.s_addr = htonl(INADDR_LOOPBACK);
LOGF("LISTEN %s see http://%s:%d", DescribeServer(), inet_ntoa(addr),
ntohs(serveraddr.sin_port));
if (printport) { if (printport) {
printf("%d\n", ntohs(serveraddr.sin_port)); printf("%d\n", ntohs(serveraddr.sin_port));
fflush(stdout); fflush(stdout);