Download
Docs

Contact
About
Docs
CVS

Reference: Logging

General

High-level logging interface.

Properties overview

  • Multiple destinations - syslog, standard output and standard error.
  • Automatic prefixing - service name and PID.

Setting parameters

  • int log_init(const char *service_name, unsigned short type, unsigned long options, int level_def);
    Must be called once, at the start of your program, to initialize logging. service_name is the name of your service, preferably all lowercase. type is the type of service you offer (see below). options are a bitwise-or of the options you want to set (see below). The default logging level is set with level_def.

    Supported values for type:
    LOG_TYPE_GENERIC: Most direct-user programs.
    LOG_TYPE_DAEMON: Background processes/servers.
    LOG_TYPE_SECURITY: Security applications that need safe logging.

    Supported values for options:
    LOG_WITH_NAME: Includes service name in all log messages.
    LOG_WITH_PID: Includes process ID in all log messages. Good for multiprocess/multithreaded applications.
    LOG_TO_SYSLOG: Sends all log messages to the syslog facility, if possible.
    LOG_TO_STDERR: Any message of level LOG_EMERG to LOG_WARNING, and LOG_DEBUG is printed to stderr.
    LOG_TO_STDOUT: Any message of level LOG_INFO or LOG_NOTICE is printed to stdout.

    Supported values for level_def:
    LOG_EMERG: System is unusable.
    LOG_ALERT: Action must be taken immediately.
    LOG_CRIT: Critical conditions.
    LOG_ERR: Error conditions.
    LOG_WARNING: Warnings.
    LOG_NOTICE: Normal, but significant, condition.
    LOG_INFO: Informational message.
    LOG_DEBUG: Debug output.
     
  • void log_level_set(int level);
    Set the default logging level. All successive messages will be of level level, unless overridden.

Logging

  • void log_put(const char *format, ...);
    Writes a log message at the default level, with printf-like formatting.
     
  • void log_put_opt(int level, unsigned long options, const char *format, ...);
    Writes a log message with level level and options options, with printf-like formatting.
     
  • void log_vput_opt(int level, unsigned long options, const char *format, va_list args);
    Writes a log message with level level and options options, with vprintf-like formatting and arguments.
     

Critical halts

  • void log_put_abort(char *message);
    Aborts program execution, logging message along with the name of the function which aborted.

 

 

Flux, these web pages, and all related material are Copyright©1999-2000 Simplemente and the respective authors, and are licensed under the GNU GPL. Please see the About page for more details. Web design by Joakim Ziegler <joakim@simplemente.net>, illustrations by Belinda Laws, <boysdontcry@zombieworld.com>.