#include<cfht/cfht.h>
voidcfht_log(who,type,message)
voidcfht_logv(who,type,fmt,arg1...)
intwho;
inttype;
char*message;
char*fmt;
libcfht.a
cfht_log()
is used
to log messages to the "right" places (log files, message windows, etc.).
message is the string to be logged.
cfht_logv()
allows printf(3)
type syntax
from the variable arg list arg1, ... .
message should not be period or "\n" terminated or prefaced with program identification. All three will happen automatically. Calls from library routines must identify the routine in use in a standard way. For example, a call from a procedure named cfp_init() should look like:
cfht_logv(CFHT_LIBCFP, CFHT_LOGONLY,
(cfp_init:%d)
missing CPU, __LINE__);
The who argument identifies whether the caller is the main program or a specified library. who should be one of the following:
The type parameter identifies the kind or severity of a message and its destination. There are currently two destinations for messages. All messages are added to a log file that is maintained as a circular buffer (roll file). In addition messages that are of interest to the operator are displayed in a feedback window on the user’s console. The type parameter is one of the following:
cfp_log()
or cfp_logv()
calls during this
execution. message will be prepended to all future messages along with some
other stuff. It is intended that this type be used before any other type
and that it contain the program name. Only the real program code should
make this call. Libraries should assume that it is already done for them.
This call is an exception in that nothing is added to the log file. Note
that cfp_parse(3)
will automatically make this call. exit(EXIT_PASS);
will follow. message will be logged and displayed in the normal color. CFHTNODISP
). This message will be in the normal color.
CFHTERROR
environment
variable to a "False" value. This message will be in the error color. CFHT_LOGONLY
type. The intent is that the
code level that understands the context should issue this message to the
operator, usually just before an exit(EXIT_FAIL);
call or a punt and restart
in a server. The CFHT_ERROR
message is similar to the CFHT_DONE
message
except it is for terminal error conditions. An error occurred which will
probably result in corrupt information or failed exposure. It indicates
that the operator must fix something. If a hardware problem is described,
hardware adjustments are probably needed. If a software problem is described,
a phone call should probably be next. In both cases, the detailed information
on what happened should have already been logged using CFHT_LOGONLY
messages.
The CFHT_ERROR
message should be from a procedure near the top of the
procedure call stack since that is where the context is understood. For
example, a call to cfp_parse(3)
might look like: if ((id = cfp_parse(CFP_PAR, argc, argv))
== FAIL) {
cfp_log(CFHT_MAIN, CFHT_ERROR, par file error);
exit(EXIT_FAIL);
}
CFHT_LOGONLY
messages. errno
will
be appended to message. The errno
based message will be in parentheses
preceded with a space. CFHT_LOGONLY
message including a
call to strerror(3)
instead (see CFHT_LOGONLY
). CFHT_ERROR
and should be removed from any
code that uses it. CFHT_LOGONLY
type message before
any return(FAIL);
or return(NULL);
error return explaining why the error
occurred so the programmer can look at it later. If a failed system call
has just occurred, message should include a translation of errno
, using
a strerror(errno)
call, as in cfht_logv(CFHT_LIBCFP, CFHT_LOGONLY,
(cfp_init:%d) par open ’%s’ failed (%s),
__LINE__, FilePath,
strerror(errno));
CFHT_DEBUG
. CFHT_LOGONLY
. cfht_log()
or cfht_logv()
with the CFHT_LOG_ID
type, and the second is
the elapsed time in seconds since the last call to cfht_log()
with the
CFHT_TIMING
type. Note that if any intervening library routines also have
calls of this type in them, then unexpected (smaller) values may result
for the second time. There will also be some special network logging types in the network version.
CFHT_WARN
messages
appear in the warning color. CFHT_ERROR
, CFHT_ERRNO
, and CFHT_FATAL
messages
appear in the error color. (There used to be a separate color for CFHT_FATAL
message.) The .sessionrc
file initializes the color scheme used, the pegasus/sessiontools/conf/colorsetup.par
file allows the user to adjust the colors, and the pegasus/sessiontools/feedbackcolor
script installs the newly chosen colors for this login.
cfht_log[v]
calls. In the following, "display"
refers to messages to the user, usually to the feedback window, under the
control of the CFHTLOGU
environment variable. "log" refers to output to
the system log file, usually the "roll file", under the control of the
CFHTLOGS
environment variable. Except for the CFHTLOG[US]
variables, the
normal operating mode is for all these to be unset.
CFHT_ERROR
, CFHT_ERRNO
, and
CFHT_WARN
messages will not be displayed or logged. When unset or "On" errors
and warnings will be both displayed and logged. CFHT_WARN
messages will not be
displayed or logged. When unset or "On" warnings will be both displayed
and logged. CFHT_STATUS
messages will be displayed but they will continue to be
logged. This is used by controllers to suppress handler messages. When unset
or "Off" these messages will be displayed and logged. CFHT_DEBUG
messages from
CFHT_MAIN
callers will be logged. When unset or "Off" these messages will
be ignored. CFHT_DEBUG
messages from all libraries
will be logged. When unset or "Off" these messages will be ignored. CFHT_DEBUG
messages for library xxx will be logged. When
unset or "Off" these messages will be ignored. .,session.np
). For debugging
it can be pointed at any file, to which messages will be appended. When
unset "display" messages are ignored. /tmp/pipes/syslog.np
). For
debugging it can be pointed at any file, to which messages will be appended.
When unset "log" messages are ignored.
When both CFHTLOGU
and CFHTLOGS
are
unset, the display output (i.e., CFHTLOGU
output) is written to stderr. In
addition, if any debugging variables are set (i.e., CFHTDEBUG
, CFHTLIB
, or
CFHTLIB
xxx is "On"), the affected CFHT_DEBUG
messages plus all CFHT_LOGONLY
from the affected modules will also appear on stderr.
The CFHTLOGU
and CFHTLOGS
variables apply to the old, non-network logging mechanism. I don’t know yet
how network logging works. (What is the way one gets reasonable local debugging
support under network logging? Now one can set CFHTLOGU
or CFHTLOGS
to
a log file or just never set them to anything.)
cfht_log(CFHT_MAIN,
CFHT_LOG_ID, tcs);
.
.
.
cfht_log(CFHT_MAIN, CFHT_STATUS, Dome opening complete);
would display something like:
tcs: Dome opening complete.
and would log something like:
username 10:29:14.21, (status) - tcs: Dome opening complete.