Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Xin Wang
codes-dev
Commits
4928a7b8
Commit
4928a7b8
authored
Mar 06, 2015
by
Jonathan Jenkins
Browse files
bye-bye logging, timeline stuff
parent
9b95fe57
Changes
7
Hide whitespace changes
Inline
Side-by-side
codes/codeslogging.h
deleted
100644 → 0
View file @
9b95fe57
/*
* Copyright (C) 2013 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
/*
* (C) 2001 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
/** \defgroup codeslogging codeslogging logging interface
*
* This is a basic application logging facility. It uses printf style
* formatting and provides several mechanisms for output.
*
* @{
*/
/* This code was derived from the PVFS2 codeslogging circa vs. 2.8.1 */
/** \file
*
* Declarations for the codeslogging logging interface.
*/
#ifndef SRC_COMMON_LOGGING_CODESLOGGING_H
#define SRC_COMMON_LOGGING_CODESLOGGING_H
#include
<stdint.h>
#include
<stdarg.h>
/********************************************************************
* Visible interface
*/
#define CODESLOGGING_BUF_SIZE 1024
/* what type of timestamp to place in msgs */
enum
codeslogging_logstamp
{
CODESLOGGING_LOGSTAMP_NONE
=
0
,
CODESLOGGING_LOGSTAMP_USEC
=
1
,
CODESLOGGING_LOGSTAMP_DATETIME
=
2
,
CODESLOGGING_LOGSTAMP_THREAD
=
3
};
#define CODESLOGGING_LOGSTAMP_DEFAULT CODESLOGGING_LOGSTAMP_USEC
/* stdio is needed by codeslogging_debug_fp declaration for FILE* */
#include
<stdio.h>
int
codeslogging_enable_stderr
(
void
);
int
codeslogging_enable_file
(
const
char
*
filename
,
const
char
*
mode
);
int
codeslogging_disable
(
void
);
int
codeslogging_set_debug_mask
(
int
debug_on
,
uint64_t
mask
);
int
codeslogging_get_debug_mask
(
int
*
debug_on
,
uint64_t
*
mask
);
int
codeslogging_set_logstamp
(
enum
codeslogging_logstamp
ts
);
void
codeslogging_backtrace
(
void
);
#ifdef __GNUC__
/* do printf style type checking if built with gcc */
int
__codeslogging_debug
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
3
,
4
)));
int
codeslogging_err
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
int
__codeslogging_debug_va
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
va_list
ap
);
int
codeslogging_debug_fp
(
FILE
*
fp
,
char
prefix
,
enum
codeslogging_logstamp
ts
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
4
,
5
)));
#ifdef CODESLOGGING_DISABLE_DEBUG
#define codeslogging_debug(mask, format, f...) do {} while(0)
#define codeslogging_perf_log(format, f...) do {} while(0)
#define codeslogging_debug_enabled(__m) 0
#else
extern
int
codeslogging_debug_on
;
extern
int
codeslogging_facility
;
extern
uint64_t
codeslogging_debug_mask
;
#define codeslogging_debug_enabled(__m) \
(codeslogging_debug_on && (codeslogging_debug_mask & __m))
/* try to avoid function call overhead by checking masks in macro */
#define codeslogging_debug(mask, format, f...) \
do { \
if ((codeslogging_debug_on) && (codeslogging_debug_mask & mask) &&\
(codeslogging_facility)) \
{ \
__codeslogging_debug(mask, '?', format, ##f); \
} \
} while(0)
#define codeslogging_perf_log(format, f...) \
do { \
if ((codeslogging_debug_on) && \
(codeslogging_debug_mask & CODESLOGGING_PERFCOUNTER_DEBUG) && \
(codeslogging_facility)) \
{ \
__codeslogging_debug(CODESLOGGING_PERFCOUNTER_DEBUG, 'P', \
format, ##f); \
} \
} while(0)
#endif
/* CODESLOGGING_DISABLE_DEBUG */
/* do file and line number printouts w/ the GNU preprocessor */
#define codeslogging_ldebug(mask, format, f...) \
do { \
codeslogging_debug(mask, "%s: " format, __func__ , ##f); \
} while(0)
#define codeslogging_lerr(format, f...) \
do { \
codeslogging_err("%s line %d: " format, __FILE__ , __LINE__ , ##f); \
codeslogging_backtrace(); \
} while(0)
#else
/* ! __GNUC__ */
int
__codeslogging_debug
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
...);
int
__codeslogging_debug_stub
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
...);
int
codeslogging_err
(
const
char
*
format
,
...);
#ifdef CODESLOGGING_DISABLE_DEBUG
#define codeslogging_debug(__m, __f, f...) __codeslogging_debug_stub(__m, '?', __f, ##f);
#define codeslogging_ldebug(__m, __f, f...) __codeslogging_debug_stub(__m, '?', __f, ##f);
#define codeslogging_debug_enabled(__m) 0
#else
#define codeslogging_debug(__m, __f, f...) __codeslogging_debug(__m, '?', __f, ##f);
#define codeslogging_ldebug(__m, __f, f...) __codeslogging_debug(__m, '?', __f, ##f);
#define codeslogging_debug_enabled(__m) \
((codeslogging_debug_on != 0) && (__m & codeslogging_debug_mask))
#endif
/* CODESLOGGING_DISABLE_DEBUG */
#define codeslogging_lerr codeslogging_err
#endif
/* __GNUC__ */
#endif
/* __CODESLOGGING_H */
/* @} */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
codes/timeline.h
deleted
100644 → 0
View file @
9b95fe57
/*
* Copyright (C) 2013 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
/*
* timeline.h
*
* Created on: Jun 24, 2013
* Author: wozniak
*/
#ifndef TIMELINE_H
#define TIMELINE_H
#define TIMELINE_ENABLED 0
#if TIMELINE_ENABLED == 1
#include
<ross.h>
/**
Open filename for writing for timeline data
@return 1 on success, 0 on error
*/
int
timeline_init
(
const
char
*
filename
);
/**
Write a timeline record
@return 1 on success, 0 on error
*/
int
timeline_printf
(
const
char
*
format
,
...);
/**
Write a timeline record
@return 1 on success, 0 on error
*/
int
timeline_printf_va
(
const
char
*
format
,
va_list
ap
);
/**
Write a timeline record with typical ROSS metadata
@return 1 on success, 0 on error
*/
#define timeline_event(lp, format, args...) \
timeline_event_impl(lp, __func__, format, ##args)
int
timeline_event_impl
(
const
tw_lp
*
lp
,
const
char
*
func
,
const
char
*
format
,
...);
/**
Finalize the timeline module
*/
void
timeline_finalize
(
void
);
#else
// Set all functions to noops (return success value 1)
#define timeline_init(x) 1
#define timeline_printf(f, a...) 1
#define timeline_printf_va(f, a) 1
#define timeline_event(lp, f, a...) 1
#define timeline_finalize()
#endif
#endif
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
src/Makefile.subdir
View file @
4928a7b8
...
...
@@ -50,8 +50,6 @@ nobase_include_HEADERS = \
codes/CodesIOKernelTypes.h
\
codes/codeslexer.h
\
codes/txt_configfile.h
\
codes/codeslogging.h
\
codes/timeline.h
\
codes/codesparser.h
\
codes/quickhash.h
\
codes/configfile.h
\
...
...
@@ -105,10 +103,6 @@ src_libcodes_base_a_SOURCES = \
src/util/resource.c
\
src/util/resource-lp.c
\
src/util/local-storage-model.c
\
codes/codeslogging.h
\
src/logging/codeslogging.c
\
codes/timeline.h
\
src/logging/timeline.c
\
src/workload/codes-workload.c
\
src/workload/codes-workload-method.h
\
src/workload/methods/codes-bgp-io-wrkld.c
\
...
...
src/logging/codeslogging.c
deleted
100644 → 0
View file @
9b95fe57
/*
* Copyright (C) 2013 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
/*
* (C) 2001 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
/** \file
* \ingroup codeslogging
*
* Implementation of codeslogging interface.
*/
#include
<stdio.h>
#include
<stdarg.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<errno.h>
#include
<stdlib.h>
#include
<time.h>
#include
<sys/time.h>
#ifdef HAVE_EXECINFO_H
#include
<execinfo.h>
#endif
#include
"codes/codeslogging.h"
#include
<pthread.h>
/** controls whether debugging is on or off */
int
codeslogging_debug_on
=
0
;
/** controls the mask level for debugging messages */
uint64_t
codeslogging_debug_mask
=
0
;
enum
{
CODESLOGGING_STDERR
=
1
,
CODESLOGGING_FILE
=
2
,
};
/** determines which logging facility to use. Default to stderr to begin
* with.
*/
int
codeslogging_facility
=
CODESLOGGING_STDERR
;
/* file handle used for file logging */
static
FILE
*
internal_log_file
=
NULL
;
/* what type of timestamp to put on logs */
static
enum
codeslogging_logstamp
internal_logstamp
=
CODESLOGGING_LOGSTAMP_DEFAULT
;
/*****************************************************************
* prototypes
*/
static
int
codeslogging_disable_stderr
(
void
);
static
int
codeslogging_disable_file
(
void
);
static
int
codeslogging_debug_fp_va
(
FILE
*
fp
,
char
prefix
,
const
char
*
format
,
va_list
ap
,
enum
codeslogging_logstamp
ts
);
/*****************************************************************
* visible functions
*/
/** Turns on logging to stderr.
*
* \return 0 on success, -errno on failure.
*/
int
codeslogging_enable_stderr
(
void
)
{
/* keep up with the existing logging settings */
int
tmp_debug_on
=
codeslogging_debug_on
;
uint64_t
tmp_debug_mask
=
codeslogging_debug_mask
;
/* turn off any running facility */
codeslogging_disable
();
codeslogging_facility
=
CODESLOGGING_STDERR
;
/* restore the logging settings */
codeslogging_debug_on
=
tmp_debug_on
;
codeslogging_debug_mask
=
tmp_debug_mask
;
return
0
;
}
/** Turns on logging to a file. The filename argument indicates which
* file to use for logging messages, and the mode indicates whether the
* file should be truncated or appended (see fopen() man page).
*
* \return 0 on success, -errno on failure.
*/
int
codeslogging_enable_file
(
const
char
*
filename
,
const
char
*
mode
)
{
/* keep up with the existing logging settings */
int
tmp_debug_on
=
codeslogging_debug_on
;
uint64_t
tmp_debug_mask
=
codeslogging_debug_mask
;
/* turn off any running facility */
codeslogging_disable
();
internal_log_file
=
fopen
(
filename
,
mode
);
if
(
!
internal_log_file
)
{
return
-
errno
;
}
codeslogging_facility
=
CODESLOGGING_FILE
;
/* restore the logging settings */
codeslogging_debug_on
=
tmp_debug_on
;
codeslogging_debug_mask
=
tmp_debug_mask
;
return
0
;
}
/** Turns off any active logging facility and disables debugging.
*
* \return 0 on success, -errno on failure.
*/
int
codeslogging_disable
(
void
)
{
int
ret
=
-
EINVAL
;
switch
(
codeslogging_facility
)
{
case
CODESLOGGING_STDERR
:
ret
=
codeslogging_disable_stderr
();
break
;
case
CODESLOGGING_FILE
:
ret
=
codeslogging_disable_file
();
break
;
default:
break
;
}
codeslogging_debug_on
=
0
;
codeslogging_debug_mask
=
0
;
return
ret
;
}
/** Fills in args indicating whether debugging is on or off, and what the
* mask level is.
*
* \return 0 on success, -errno on failure.
*/
int
codeslogging_get_debug_mask
(
int
*
debug_on
,
uint64_t
*
mask
)
{
*
debug_on
=
codeslogging_debug_on
;
*
mask
=
codeslogging_debug_mask
;
return
0
;
}
/** Determines whether debugging messages are turned on or off. Also
* specifies the mask that determines which debugging messages are
* printed.
*
* \return 0 on success, -errno on failure.
*/
int
codeslogging_set_debug_mask
(
int
debug_on
,
uint64_t
mask
)
{
if
((
debug_on
!=
0
)
&&
(
debug_on
!=
1
))
{
return
-
EINVAL
;
}
codeslogging_debug_on
=
debug_on
;
codeslogging_debug_mask
=
mask
;
return
0
;
}
/* codeslogging_set_logstamp()
*
* sets timestamp style for codeslogging messages
*
* returns 0 on success, -errno on failure
*/
int
codeslogging_set_logstamp
(
enum
codeslogging_logstamp
ts
)
{
internal_logstamp
=
ts
;
return
(
0
);
}
#ifndef __GNUC__
/* __codeslogging_debug_stub()
*
* stub for codeslogging_debug that doesn't do anything; used when debugging
* is "compiled out" on non-gcc builds
*
* returns 0
*/
int
__codeslogging_debug_stub
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
...)
{
return
0
;
}
#endif
/* __codeslogging_debug()
*
* Logs a standard debugging message. It will not be printed unless the
* mask value matches (logical "and" operation) with the mask specified in
* codeslogging_set_debug_mask() and debugging is turned on.
*
* returns 0 on success, -errno on failure
*/
int
__codeslogging_debug
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
...)
{
int
ret
=
-
EINVAL
;
va_list
ap
;
/* rip out the variable arguments */
va_start
(
ap
,
format
);
ret
=
__codeslogging_debug_va
(
mask
,
prefix
,
format
,
ap
);
va_end
(
ap
);
return
ret
;
}
int
__codeslogging_debug_va
(
uint64_t
mask
,
char
prefix
,
const
char
*
format
,
va_list
ap
)
{
int
ret
=
-
EINVAL
;
/* NOTE: this check happens in the macro (before making a function call)
* if we use gcc
*/
#ifndef __GNUC__
/* exit quietly if we aren't meant to print */
if
((
!
codeslogging_debug_on
)
||
!
(
codeslogging_debug_mask
&
mask
)
||
(
!
codeslogging_facility
))
{
return
0
;
}
#endif
if
(
prefix
==
'?'
)
{
/* automatic prefix assignment */
prefix
=
'D'
;
}
switch
(
codeslogging_facility
)
{
case
CODESLOGGING_STDERR
:
ret
=
codeslogging_debug_fp_va
(
stderr
,
prefix
,
format
,
ap
,
internal_logstamp
);
break
;
case
CODESLOGGING_FILE
:
ret
=
codeslogging_debug_fp_va
(
internal_log_file
,
prefix
,
format
,
ap
,
internal_logstamp
);
break
;
default:
break
;
}
return
ret
;
}
/** Logs a critical error message. This will print regardless of the
* mask value and whether debugging is turned on or off, as long as some
* logging facility has been enabled.
*
* \return 0 on success, -errno on failure.
*/
int
codeslogging_err
(
const
char
*
format
,
...)
{
va_list
ap
;
int
ret
=
-
EINVAL
;
if
(
!
codeslogging_facility
)
{
return
0
;
}
/* rip out the variable arguments */
va_start
(
ap
,
format
);
switch
(
codeslogging_facility
)
{
case
CODESLOGGING_STDERR
:
ret
=
codeslogging_debug_fp_va
(
stderr
,
'E'
,
format
,
ap
,
internal_logstamp
);
break
;
case
CODESLOGGING_FILE
:
ret
=
codeslogging_debug_fp_va
(
internal_log_file
,
'E'
,
format
,
ap
,
internal_logstamp
);
break
;
default:
break
;
}
va_end
(
ap
);
return
ret
;
}
#ifdef CODESLOGGING_ENABLE_BACKTRACE
#ifndef CODESLOGGING_BACKTRACE_DEPTH
#define CODESLOGGING_BACKTRACE_DEPTH 12
#endif
/** Prints out a dump of the current stack (excluding this function)
* using codeslogging_err.
*/
void
codeslogging_backtrace
(
void
)
{
void
*
trace
[
CODESLOGGING_BACKTRACE_DEPTH
];
char
**
messages
=
NULL
;
int
i
,
trace_size
;
trace_size
=
backtrace
(
trace
,
CODESLOGGING_BACKTRACE_DEPTH
);
messages
=
backtrace_symbols
(
trace
,
trace_size
);
for
(
i
=
1
;
i
<
trace_size
;
i
++
)
{
codeslogging_err
(
"
\t
[bt] %s
\n
"
,
messages
[
i
]);
}
free
(
messages
);
}
#else
void
codeslogging_backtrace
(
void
)
{
}
#endif
/****************************************************************
* Internal functions
*/
int
codeslogging_debug_fp
(
FILE
*
fp
,