mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
add set_loglevel_from_env() #2277
This commit is contained in:
parent
acb91339e4
commit
27917d12ec
@ -909,6 +909,7 @@ ncdirect* ncdirect_core_init(const char* termtype, FILE* outfp, uint64_t flags){
|
|||||||
}else{
|
}else{
|
||||||
loglevel = NCLOGLEVEL_SILENT;
|
loglevel = NCLOGLEVEL_SILENT;
|
||||||
}
|
}
|
||||||
|
set_loglevel_from_env(&loglevel);
|
||||||
int cursor_y = -1;
|
int cursor_y = -1;
|
||||||
int cursor_x = -1;
|
int cursor_x = -1;
|
||||||
if(interrogate_terminfo(&ret->tcache, ret->ttyfp, utf8, 1,
|
if(interrogate_terminfo(&ret->tcache, ret->ttyfp, utf8, 1,
|
||||||
|
@ -1746,6 +1746,10 @@ emit_scrolls(const tinfo* ti, int count, fbuf* f){
|
|||||||
// replace or populate the TERM environment variable with 'termname'
|
// replace or populate the TERM environment variable with 'termname'
|
||||||
int putenv_term(const char* termname) __attribute__ ((nonnull (1)));
|
int putenv_term(const char* termname) __attribute__ ((nonnull (1)));
|
||||||
|
|
||||||
|
// check environment for NOTCURSES_LOGLEVEL, and use it if defined.
|
||||||
|
int set_loglevel_from_env(ncloglevel_e* loglevel)
|
||||||
|
__attribute__ ((nonnull (1)));
|
||||||
|
|
||||||
#undef API
|
#undef API
|
||||||
#undef ALLOC
|
#undef ALLOC
|
||||||
|
|
||||||
|
@ -1002,6 +1002,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
|||||||
ret->rstate.f.used = 0;
|
ret->rstate.f.used = 0;
|
||||||
ret->rstate.f.size = 0;
|
ret->rstate.f.size = 0;
|
||||||
ret->loglevel = opts->loglevel;
|
ret->loglevel = opts->loglevel;
|
||||||
|
set_loglevel_from_env(&ret->loglevel);
|
||||||
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
|
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
|
||||||
init_lang();
|
init_lang();
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,22 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
int set_loglevel_from_env(ncloglevel_e* llptr){
|
||||||
|
const char* ll = getenv("NOTCURSES_LOGLEVEL");
|
||||||
|
if(ll == NULL){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
char* endl;
|
||||||
|
long l = strtol(ll, &endl, 10);
|
||||||
|
if(l < NCLOGLEVEL_PANIC || l > NCLOGLEVEL_TRACE){
|
||||||
|
logpanic("Illegal NOTCURSES_LOGLEVEL: %s\n", ll);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*llptr = l;
|
||||||
|
loginfo("Got loglevel from environment: %ld\n", l);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
char* notcurses_accountname(void){
|
char* notcurses_accountname(void){
|
||||||
#ifndef __MINGW64__
|
#ifndef __MINGW64__
|
||||||
const char* un;
|
const char* un;
|
||||||
|
Loading…
Reference in New Issue
Block a user