Changeset e0c836e8 in mainline


Ignore:
Timestamp:
2012-09-07T08:29:43Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42bde6a
Parents:
70253688
Message:

Add comments to logging interface in libc

Location:
uspace/lib/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/log.c

    r70253688 re0c836e8  
    4343#include <ns.h>
    4444
     45/** Id of the first log we create at logger. */
    4546static sysarg_t default_log_id;
    4647
     
    4849static const char *log_prog_name;
    4950
     51/** Names of individual log levels. */
    5052static const char *log_level_names[] = {
    5153        "fatal",
     
    6466#define MESSAGE_BUFFER_SIZE 4096
    6567
     68/** Send formatted message to the logger service.
     69 *
     70 * @param session Initialized IPC session with the logger.
     71 * @param log Log to use.
     72 * @param level Verbosity level of the message.
     73 * @param message The actual message.
     74 * @return Error code of the conversion or EOK on success.
     75 */
    6676static int logger_message(async_sess_t *session, log_t log, log_level_t level, char *message)
    6777{
     
    98108}
    99109
     110/** Get name of the log level.
     111 *
     112 * @param level The log level.
     113 * @return String name or "unknown".
     114 */
    100115const char *log_level_str(log_level_t level)
    101116{
     
    106121}
    107122
     123/** Convert log level name to the enum.
     124 *
     125 * @param[in] name Log level name or log level number.
     126 * @param[out] level_out Where to store the result (set to NULL to ignore).
     127 * @return Error code of the conversion or EOK on success.
     128 */
    108129int log_level_from_str(const char *name, log_level_t *level_out)
    109130{
     
    137158/** Initialize the logging system.
    138159 *
    139  * @param prog_name     Program name, will be printed as part of message
     160 * @param prog_name Program name, will be printed as part of message
    140161 */
    141162int log_init(const char *prog_name)
     
    190211/** Write an entry to the log.
    191212 *
    192  * @param level         Message verbosity level. Message is only printed
    193  *                      if verbosity is less than or equal to current
    194  *                      reporting level.
    195  * @param fmt           Format string (no traling newline).
     213 * The message is printed only if the verbosity level is less than or
     214 * equal to currently set reporting level of the log.
     215 *
     216 * @param ctx Log to use (use LOG_DEFAULT if you have no idea what it means).
     217 * @param level Severity level of the message.
     218 * @param fmt Format string in printf-like format (without trailing newline).
    196219 */
    197220void log_msg(log_t ctx, log_level_t level, const char *fmt, ...)
     
    206229/** Write an entry to the log (va_list variant).
    207230 *
    208  * @param level         Message verbosity level. Message is only printed
    209  *                      if verbosity is less than or equal to current
    210  *                      reporting level.
    211  * @param fmt           Format string (no trailing newline)
     231 * @param ctx Log to use (use LOG_DEFAULT if you have no idea what it means).
     232 * @param level Severity level of the message.
     233 * @param fmt Format string in printf-like format (without trailing newline).
     234 * @param args Arguments.
    212235 */
    213236void log_msgv(log_t ctx, log_level_t level, const char *fmt, va_list args)
  • uspace/lib/c/generic/io/logctl.c

    r70253688 re0c836e8  
    6565}
    6666
    67 
     67/** Set default reported log level (global setting).
     68 *
     69 * This setting affects all logger clients whose reporting level was
     70 * not yet changed.
     71 *
     72 * If logging level of client A is changed with logctl_set_log_level()
     73 * to some level, this call will have no effect at that client's reporting
     74 * level. Even if the actual value of the reporting level of client A is
     75 * the same as current (previous) default log level.
     76 *
     77 * @param new_level New reported logging level.
     78 * @return Error code of the conversion or EOK on success.
     79 */
    6880int logctl_set_default_level(log_level_t new_level)
    6981{
     
    8193}
    8294
     95/** Set reported log level of a single log.
     96 *
     97 * @see logctl_set_default_level
     98 *
     99 * @param logname Log name.
     100 * @param new_level New reported logging level.
     101 * @return Error code of the conversion or EOK on success.
     102 */
    83103int logctl_set_log_level(const char *logname, log_level_t new_level)
    84104{
  • uspace/lib/c/include/io/log.h

    r70253688 re0c836e8  
    3939#include <io/verify.h>
    4040
     41/** Log message level. */
    4142typedef enum {
     43        /** Fatal error, program is not able to recover at all. */
    4244        LVL_FATAL,
     45        /** Serious error but the program can recover from it. */
    4346        LVL_ERROR,
     47        /** Easily recoverable problem. */
    4448        LVL_WARN,
     49        /** Information message that ought to be printed by default. */
    4550        LVL_NOTE,
     51        /** Debugging purpose message. */
    4652        LVL_DEBUG,
     53        /** More detailed debugging message. */
    4754        LVL_DEBUG2,
    4855       
     
    5158} log_level_t;
    5259
     60/** Log itself (logging target). */
    5361typedef sysarg_t log_t;
     62/** Formatting directive for printing log_t. */
    5463#define PRIlogctx PRIxn
     64
     65/** Default log (target). */
    5566#define LOG_DEFAULT ((log_t) -1)
     67
     68/** Use when creating new top-level log. */
    5669#define LOG_NO_PARENT ((log_t) 0)
    5770
Note: See TracChangeset for help on using the changeset viewer.