Skip to content

Commit

Permalink
level1
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Sep 20, 2023
1 parent 1b3ac31 commit 08198cf
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions include/nclog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ extern "C" {
#endif

EXTERNL void ncloginit(void);
EXTERNL int ncsetlogging(int tf);
EXTERNL int ncsetloglevel(int level);
EXTERNL int nclogopen(FILE* stream);

/* The tag value is an arbitrary integer */
EXTERNL void nclog(int tag, const char* fmt, ...);
EXTERNL int ncvlog(int tag, const char* fmt, va_list ap);
EXTERNL void ncvlog(int tag, const char* fmt, va_list ap);
EXTERNL void nclogtext(int tag, const char* text);
EXTERNL void nclogtextn(int tag, const char* text, size_t count);

Expand Down
3 changes: 1 addition & 2 deletions libdap2/ncd2dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ fprintf(stderr,"ce=%s\n",dumpconstraint(dapcomm->oc.dapconstraint));

/* Turn on logging; only do this after oc_open*/
if((value = dapparamvalue(dapcomm,"log")) != NULL) {
ncsetlogging(1);
nclogopen(NULL);
ncsetloglevel(NCLOGNOTE);
}

/* fetch and build the unconstrained DDS for use as
Expand Down
2 changes: 1 addition & 1 deletion libdap4/d4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ NCD4_open(const char * path, int mode,
/* Turn on logging; only do this after oc_open*/
if((value = ncurifragmentlookup(d4info->uri,"log")) != NULL) {
ncloginit();
ncsetlogging(1);
ncsetloglevel(NCLOGNOTE);
}

/* Check env values */
Expand Down
10 changes: 3 additions & 7 deletions libdispatch/nclog.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ static struct NCLOGGLOBAL {
} nclog_global = {0,-1,NULL};

static const char* nctagset[] = {"Error","Warning","Note","Debug"};
static const int nctagsize = sizeof(nctagset)/sizeof(char*);

/* Forward */
static const char* nctagname(int tag);
Expand All @@ -74,7 +73,7 @@ ncloginit(void)
/* Use environment variables to preset nclogging state*/
envv = getenv(NCENVLOGGING);
if(envv != NULL) ncsetloglevel(atoi(envv));
envv = getenv(NCENVTRACEING);
envv = getenv(NCENVTRACING);
if(envv != NULL) nctracelevel(atoi(envv));
}

Expand Down Expand Up @@ -135,7 +134,7 @@ ncvlog(int level, const char* fmt, va_list ap)
if(!nclogginginitialized) ncloginit();
if(nclog_global.loglevel > level || nclog_global.nclogstream == NULL)
return;
prefix = nctagname(tag);
prefix = nctagname(level);
fprintf(nclog_global.nclogstream,"%s: ",prefix);
if(fmt != NULL) {
vfprintf(nclog_global.nclogstream, fmt, ap);
Expand All @@ -160,7 +159,7 @@ Each line will be sent using nclog with the specified tag.
void
nclogtextn(int level, const char* text, size_t count)
{
if(nclog_global.level > level || nclog_global.nclogstream == NULL)
if(nclog_global.loglevel > level || nclog_global.nclogstream == NULL)
return;
fwrite(text,1,count,nclog_global.nclogstream);
fflush(nclog_global.nclogstream);
Expand Down Expand Up @@ -188,10 +187,8 @@ nctracelevel(int level)
oldlevel = nclog_global.tracelevel;
if(level < 0) {
nclog_global.tracelevel = level;
ncsetlogging(0);
} else { /*(level >= 0)*/
nclog_global.tracelevel = level;
ncsetlogging(1);
nclogopen(NULL); /* use stderr */
}
return oldlevel;
Expand Down Expand Up @@ -220,7 +217,6 @@ ncvtrace(int level, const char* fcn, const char* fmt, va_list ap)
{
struct Frame* frame;
if(!nclogginginitialized) ncloginit();
if(nclog_global.tracelevel < 0) ncsetlogging(0);
if(fcn != NULL) {
frame = &nclog_global.frames[nclog_global.depth];
frame->fcn = fcn;
Expand Down
2 changes: 1 addition & 1 deletion libnczarr/zarr.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ applycontrols(NCZ_FILE_INFO_T* zinfo)
/* Process other controls */
if((value = controllookup((const char**)zinfo->envv_controls,"log")) != NULL) {
zinfo->controls.flags |= FLAG_LOGGING;
ncsetlogging(1);
ncsetloglevel(NCLOGNOTE);
}
if((value = controllookup((const char**)zinfo->envv_controls,"show")) != NULL) {
if(strcasecmp(value,"fetch")==0)
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ncdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,7 +2397,7 @@ main(int argc, char *argv[])
nc_set_log_level(level);
}
#endif
ncsetlogging(1);
ncsetloglevel(NCLOGNOTE);
break;
case 'F':
formatting_specs.filter_atts = true;
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ocprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ main(int argc, char **argv)

if(ocopt.logging) {
ncloginit();
ncsetlogging(1);
ncsetloglevel(NCLOGNOTE);
if(!nclogopen(NULL))
fprintf(stderr,"Failed to open logging output\n");
}
Expand Down

0 comments on commit 08198cf

Please sign in to comment.