Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b52dd1de in mainline


Ignore:
Timestamp:
2012-08-16T09:39:07Z (9 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
5882487
Parents:
0a6a996
Message:

Initial logging level can be set through sysinfo

Location:
uspace
Files:
3 edited

Legend:

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

    r0a6a996 rb52dd1de  
    3636#include <io/logctl.h>
    3737#include <ipc/logger.h>
     38#include <sysinfo.h>
    3839#include <ns.h>
     40
     41#define SYSINFO_DEFAULT_LOG_LEVEL "logger.level"
    3942
    4043/** IPC session with the logger service. */
     
    7376}
    7477
     78int logctl_get_boot_level(log_level_t *level)
     79{
     80        sysarg_t boot_level_arg;
     81        int rc = sysinfo_get_value(SYSINFO_DEFAULT_LOG_LEVEL, &boot_level_arg);
     82        if (rc != EOK)
     83                return rc;
     84
     85        log_level_t boot_level = (log_level_t) boot_level_arg;
     86        if (boot_level >= LVL_LIMIT)
     87                return EINVAL;
     88
     89        if (level != NULL)
     90                *level = (log_level_t) boot_level;
     91
     92        return EOK;
     93}
     94
    7595/** @}
    7696 */
  • uspace/lib/c/include/io/logctl.h

    r0a6a996 rb52dd1de  
    3737
    3838extern int logctl_set_default_level(log_level_t);
     39extern int logctl_get_boot_level(log_level_t *);
    3940
    4041#endif
  • uspace/srv/logger/main.c

    r0a6a996 rb52dd1de  
    3939#include <ipc/logger.h>
    4040#include <io/log.h>
     41#include <io/logctl.h>
    4142#include <ns.h>
    4243#include <async.h>
     
    189190        printf(NAME ": HelenOS Logging Service\n");
    190191       
     192        /* Get default logging level from sysinfo (if available). */
     193        log_level_t boot_logging_level = LVL_NOTE;
     194        int rc = logctl_get_boot_level(&boot_logging_level);
     195        if (rc == EOK)
     196                set_default_logging_level(boot_logging_level);
     197        else
     198                printf(NAME ": Warn: failed to get logging level from sysinfo: %s.\n",
     199                    str_error(rc));
     200
    191201        async_set_client_connection(connection_handler);
    192202       
    193         int rc = service_register(SERVICE_LOGGER);
     203        rc = service_register(SERVICE_LOGGER);
    194204        if (rc != EOK) {
    195205                printf(NAME ": failed to register: %s.\n", str_error(rc));
Note: See TracChangeset for help on using the changeset viewer.