Ticket #307: devman_logging.patch

File devman_logging.patch, 20.8 KB (added by Vojtech Horky, 13 years ago)

Patch for conditional printing of devman messages

  • uspace/srv/devman/Makefile

    === modified file 'uspace/srv/devman/Makefile'
     
    3131BINARY = devman
    3232
    3333SOURCES = \
     34        log.c \
    3435        main.c \
    3536        devman.c \
    3637        match.c \
  • uspace/srv/devman/devman.c

    === modified file 'uspace/srv/devman/devman.c'
     
    3939#include <str_error.h>
    4040
    4141#include "devman.h"
     42#include "log.h"
    4243
    4344fun_node_t *find_node_child(fun_node_t *parent, const char *name);
    4445
     
    145146        list_prepend(&drv->drivers, &drivers_list->drivers);
    146147        fibril_mutex_unlock(&drivers_list->drivers_mutex);
    147148
    148         printf(NAME": the '%s' driver was added to the list of available "
     149        devman_log_info("Driver `%s' was added to the list of available "
    149150            "drivers.\n", drv->name);
    150151}
    151152
     
    236237 */
    237238bool read_match_ids(const char *conf_path, match_id_list_t *ids)
    238239{
    239         printf(NAME ": read_match_ids conf_path = %s.\n", conf_path);
     240        devman_log_debug("read_match_ids(conf_path=\"%s\")\n", conf_path);
    240241       
    241242        bool suc = false;
    242243        char *buf = NULL;
     
    246247       
    247248        fd = open(conf_path, O_RDONLY);
    248249        if (fd < 0) {
    249                 printf(NAME ": unable to open %s\n", conf_path);
     250                devman_log_error("Unable to open `%s' for reading: %s.\n",
     251                    conf_path, str_error(fd));
    250252                goto cleanup;
    251253        }
    252254        opened = true;
     
    254256        len = lseek(fd, 0, SEEK_END);
    255257        lseek(fd, 0, SEEK_SET);
    256258        if (len == 0) {
    257                 printf(NAME ": configuration file '%s' is empty.\n", conf_path);
     259                devman_log_error("Configuration file `%s' is empty.\n",
     260                    conf_path);
    258261                goto cleanup;
    259262        }
    260263       
    261264        buf = malloc(len + 1);
    262265        if (buf == NULL) {
    263                 printf(NAME ": memory allocation failed when parsing file "
    264                     "'%s'.\n", conf_path);
     266                devman_log_error("Memory allocation failed when parsing file "
     267                    "`%s'.\n", conf_path);
    265268                goto cleanup;
    266269        }
    267270       
    268271        if (read(fd, buf, len) <= 0) {
    269                 printf(NAME ": unable to read file '%s'.\n", conf_path);
     272                devman_log_error("Unable to read file `%s'.\n", conf_path);
    270273                goto cleanup;
    271274        }
    272275        buf[len] = 0;
     
    304307 */
    305308bool get_driver_info(const char *base_path, const char *name, driver_t *drv)
    306309{
    307         printf(NAME ": get_driver_info base_path = %s, name = %s.\n",
     310        devman_log_debug("get_driver_info(base_path=\"%s\", name=\"%s\")\n",
    308311            base_path, name);
    309312       
    310313        assert(base_path != NULL && name != NULL && drv != NULL);
     
    336339        /* Check whether the driver's binary exists. */
    337340        struct stat s;
    338341        if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */
    339                 printf(NAME ": driver not found at path %s.", drv->binary_path);
     342                devman_log_error("Driver not found at path `%s'.",
     343                    drv->binary_path);
    340344                goto cleanup;
    341345        }
    342346       
     
    363367 */
    364368int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path)
    365369{
    366         printf(NAME ": lookup_available_drivers, dir = %s \n", dir_path);
     370        devman_log_debug("lookup_available_drivers(dir=\"%s\")\n", dir_path);
    367371       
    368372        int drv_cnt = 0;
    369373        DIR *dir = NULL;
     
    397401        fun_node_t *fun;
    398402        dev_node_t *dev;
    399403       
    400         printf(NAME ": create_root_nodes\n");
     404        devman_log_debug("create_root_nodes()\n");
    401405       
    402406        fibril_rwlock_write_lock(&tree->rwlock);
    403407       
     
    482486 */
    483487void attach_driver(dev_node_t *dev, driver_t *drv)
    484488{
    485         printf(NAME ": attach_driver %s to device %s\n",
    486             drv->name, dev->pfun->pathname);
     489        devman_log_debug("attach_driver(dev=\"%s\",drv=\"%s\")\n",
     490            dev->pfun->pathname, drv->name);
    487491       
    488492        fibril_mutex_lock(&drv->driver_mutex);
    489493       
     
    505509
    506510        assert(fibril_mutex_is_locked(&drv->driver_mutex));
    507511       
    508         printf(NAME ": start_driver '%s'\n", drv->name);
     512        devman_log_debug("start_driver(drv=\"%s\")\n", drv->name);
    509513       
    510514        rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
    511515        if (rc != EOK) {
    512                 printf(NAME ": error spawning %s (%s)\n",
    513                     drv->name, str_error(rc));
     516                devman_log_error("Spawning driver `%s' (%s) failed: %s.\n",
     517                    drv->name, drv->binary_path, str_error(rc));
    514518                return false;
    515519        }
    516520       
     
    572576        link_t *link;
    573577        int phone;
    574578
    575         printf(NAME ": pass_devices_to_driver(`%s')\n", driver->name);
     579        devman_log_debug("pass_devices_to_driver(driver=\"%s\")\n",
     580            driver->name);
    576581
    577582        fibril_mutex_lock(&driver->driver_mutex);
    578583
     
    639644         * the driver would be added to the device list and started
    640645         * immediately and possibly started here as well.
    641646         */
    642         printf(NAME ": driver %s goes into running state.\n", driver->name);
     647        devman_log_debug("Driver `%s' enters running state.\n", driver->name);
    643648        driver->state = DRIVER_RUNNING;
    644649
    645650        fibril_mutex_unlock(&driver->driver_mutex);
     
    656661 */
    657662void initialize_running_driver(driver_t *driver, dev_tree_t *tree)
    658663{
    659         printf(NAME ": initialize_running_driver (`%s')\n", driver->name);
     664        devman_log_debug("initialize_running_driver(driver=\"%s\")\n",
     665            driver->name);
    660666       
    661667        /*
    662668         * Pass devices which have been already assigned to the driver to the
     
    746752         * We do not expect to have driver's mutex locked as we do not
    747753         * access any structures that would affect driver_t.
    748754         */
    749         printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name,
    750             dev->pfun->name);
     755        devman_log_debug("add_device(drv=\"%s\", dev=\"%s\")\n",
     756            drv->name, dev->pfun->name);
    751757       
    752758        sysarg_t rc;
    753759        ipc_call_t answer;
     
    808814         */
    809815        driver_t *drv = find_best_match_driver(drivers_list, dev);
    810816        if (drv == NULL) {
    811                 printf(NAME ": no driver found for device '%s'.\n",
     817                devman_log_error("No driver found for device `%s'.\n",
    812818                    dev->pfun->pathname);
    813819                return false;
    814820        }
     
    846852 */
    847853bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list)
    848854{
    849         printf(NAME ": init_device_tree.\n");
     855        devman_log_debug("init_device_tree()\n");
    850856       
    851857        tree->current_handle = 0;
    852858       
     
    10251031       
    10261032        fun->pathname = (char *) malloc(pathsize);
    10271033        if (fun->pathname == NULL) {
    1028                 printf(NAME ": failed to allocate device path.\n");
     1034                devman_log_error("Failed to allocate device path.\n");
    10291035                return false;
    10301036        }
    10311037       
     
    10561062        assert(tree != NULL);
    10571063        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    10581064       
     1065        devman_log_debug("insert_dev_node(dev=%p, pfun=%p [\"%s\"])\n",
     1066            dev, pfun, pfun->pathname);
     1067
    10591068        /* Add the node to the handle-to-node map. */
    10601069        dev->handle = ++tree->current_handle;
    10611070        unsigned long key = dev->handle;
    10621071        hash_table_insert(&tree->devman_devices, &key, &dev->devman_dev);
    10631072
    10641073        /* Add the node to the list of its parent's children. */
    1065         printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun);
    10661074        dev->pfun = pfun;
    10671075        pfun->child = dev;
    10681076       
  • uspace/srv/devman/log.c

    === added file 'uspace/srv/devman/log.c'
     
     1/*
     2 * Copyright (c) 2011 Vojtech Horky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** @addtogroup devman
     30 * @{
     31 */
     32
     33#include <stdlib.h>
     34#include <stdio.h>
     35#include <fibril_synch.h>
     36
     37#include "log.h"
     38#include "devman.h"
     39
     40#define LOG_FILENAME "/log/" NAME
     41
     42/** Serialization mutex for logging functions. */
     43static FIBRIL_MUTEX_INITIALIZE(log_serializer);
     44
     45/** File where to store the log. */
     46static FILE *log_file = NULL;
     47
     48/** Current log level. */
     49static devman_log_level_t log_level;
     50
     51/** Prefixes for individual logging levels. */
     52static const char *log_level_names[] = {
     53        "error: ",
     54        "",
     55        "debug: "
     56};
     57
     58/** Initialize the logging system. */
     59void devman_log_init(devman_log_level_t level)
     60{
     61        assert(level < DEVMAN_LOG_LEVEL_MAX);
     62
     63        log_level = level;
     64        if (log_file == NULL) {
     65                log_file = fopen(LOG_FILENAME, "w");
     66        }
     67}
     68
     69/** Put single entry to the log. */
     70void devman_log(devman_log_level_t level, const char *format, ...)
     71{
     72        assert(level < DEVMAN_LOG_LEVEL_MAX);
     73
     74        FILE *screen_output = NULL;
     75        if (level == DEVMAN_LOG_LEVEL_ERROR) {
     76                screen_output = stderr;
     77        } else {
     78                screen_output = stdout;
     79        }
     80
     81        va_list args;
     82
     83        /*
     84         * Serialize access to log files.
     85         * Always print to log file, to screen print only when the enabled
     86         * log level is high enough.
     87         */
     88        fibril_mutex_lock(&log_serializer);
     89
     90        if (log_file != NULL) {
     91                va_start(args, format);
     92
     93                fprintf(log_file, "%s", log_level_names[level]);
     94                vfprintf(log_file, format, args);
     95                fflush(log_file);
     96
     97                va_end(args);
     98        }
     99
     100        if (level <= log_level) {
     101                va_start(args, format);
     102
     103                fprintf(screen_output, "%s: %s", NAME, log_level_names[level]);
     104                vfprintf(screen_output, format, args);
     105                fflush(screen_output);
     106
     107                va_end(args);
     108        }
     109
     110        fibril_mutex_unlock(&log_serializer);
     111}
     112
     113
     114/** @}
     115 */
  • uspace/srv/devman/log.h

    === added file 'uspace/srv/devman/log.h'
     
     1/*
     2 * Copyright (c) 2011 Vojtech Horky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** @addtogroup devman
     30 * @{
     31 */
     32
     33#ifndef DEVMAN_LOG_H_
     34#define DEVMAN_LOG_H_
     35
     36typedef enum {
     37        DEVMAN_LOG_LEVEL_ERROR,
     38        DEVMAN_LOG_LEVEL_INFO,
     39        DEVMAN_LOG_LEVEL_DEBUG,
     40        DEVMAN_LOG_LEVEL_MAX
     41} devman_log_level_t;
     42
     43extern void devman_log(devman_log_level_t, const char *, ...);
     44extern void devman_log_init(devman_log_level_t);
     45#define devman_log_error(format, ...) \
     46        devman_log(DEVMAN_LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
     47#define devman_log_info(format, ...) \
     48        devman_log(DEVMAN_LOG_LEVEL_INFO, format, ##__VA_ARGS__)
     49#define devman_log_debug(format, ...) \
     50        devman_log(DEVMAN_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
     51
     52#endif
     53
     54/** @}
     55 */
  • uspace/srv/devman/main.c

    === modified file 'uspace/srv/devman/main.c'
     
    4242#include <async.h>
    4343#include <stdio.h>
    4444#include <errno.h>
     45#include <str_error.h>
    4546#include <bool.h>
    4647#include <fibril_synch.h>
    4748#include <stdlib.h>
     
    5657#include <devmap.h>
    5758
    5859#include "devman.h"
     60#include "log.h"
    5961
    6062#define DRIVER_DEFAULT_STORE  "/drv"
    6163
     
    7072        ipc_callid_t iid;
    7173        driver_t *driver = NULL;
    7274
    73         printf(NAME ": devman_driver_register \n");
     75        devman_log_debug("devman_driver_register\n");
    7476       
    7577        iid = async_get_call(&icall);
    7678        if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) {
     
    8789                return NULL;
    8890        }
    8991
    90         printf(NAME ": the %s driver is trying to register by the service.\n",
     92        devman_log_debug("The `%s' driver is trying to register.\n",
    9193            drv_name);
    9294       
    9395        /* Find driver structure. */
    9496        driver = find_driver(&drivers_list, drv_name);
    9597       
    9698        if (driver == NULL) {
    97                 printf(NAME ": no driver named %s was found.\n", drv_name);
     99                devman_log_error("No driver named `%s' was found.\n", drv_name);
    98100                free(drv_name);
    99101                drv_name = NULL;
    100102                async_answer_0(iid, ENOENT);
     
    105107        drv_name = NULL;
    106108       
    107109        /* Create connection to the driver. */
    108         printf(NAME ":  creating connection to the %s driver.\n", driver->name);
     110        devman_log_debug("Creating connection to the `%s' driver.\n",
     111            driver->name);
    109112        ipc_call_t call;
    110113        ipc_callid_t callid = async_get_call(&call);
    111114        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
     
    117120        /* Remember driver's phone. */
    118121        set_driver_phone(driver, IPC_GET_ARG5(call));
    119122       
    120         printf(NAME ": the %s driver was successfully registered as running.\n",
     123        devman_log_info(
     124            "The `%s' driver was successfully registered as running.\n",
    121125            driver->name);
    122126       
    123127        async_answer_0(callid, EOK);
     
    141145       
    142146        callid = async_get_call(&call);
    143147        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    144                 printf(NAME ": ERROR: devman_receive_match_id - invalid "
    145                     "protocol.\n");
     148                devman_log_error(
     149                    "Invalid protocol when trying to receive match id.\n");
    146150                async_answer_0(callid, EINVAL);
    147151                delete_match_id(match_id);
    148152                return EINVAL;
    149153        }
    150154       
    151155        if (match_id == NULL) {
    152                 printf(NAME ": ERROR: devman_receive_match_id - failed to "
    153                     "allocate match id.\n");
     156                devman_log_error("Failed to allocate match id.\n");
    154157                async_answer_0(callid, ENOMEM);
    155158                return ENOMEM;
    156159        }
     
    164167        match_id->id = match_id_str;
    165168        if (rc != EOK) {
    166169                delete_match_id(match_id);
    167                 printf(NAME ": devman_receive_match_id - failed to receive "
    168                     "match id string.\n");
     170                devman_log_error("Failed to receive match id string: %s.\n",
     171                    str_error(rc));
    169172                return rc;
    170173        }
    171174       
    172175        list_append(&match_id->link, &match_ids->ids);
    173176       
    174         printf(NAME ": received match id '%s', score = %d \n",
     177        devman_log_debug("Received match id `%s', score %d.\n",
    175178            match_id->id, match_id->score);
    176179        return rc;
    177180}
     
    227230       
    228231        if (ftype != fun_inner && ftype != fun_exposed) {
    229232                /* Unknown function type */
    230                 printf(NAME ": Error, unknown function type provided by driver!\n");
     233                devman_log_error(
     234                    "Unknown function type %d provided by driver.\n",
     235                    (int) ftype);
    231236
    232237                fibril_rwlock_write_unlock(&tree->rwlock);
    233238                async_answer_0(callid, EINVAL);
     
    264269
    265270        fibril_rwlock_write_unlock(&tree->rwlock);
    266271       
    267         printf(NAME ": devman_add_function %s\n", fun->pathname);
     272        devman_log_debug("devman_add_function(fun=\"%s\")\n", fun->pathname);
    268273       
    269274        devman_receive_match_ids(match_count, &fun->match_ids);
    270275
     
    346351        /* Register the device's class alias by devmapper. */
    347352        devmap_register_class_dev(class_info);
    348353       
    349         printf(NAME ": function'%s' added to class '%s', class name '%s' was "
    350             "asigned to it\n", fun->pathname, class_name, class_info->dev_name);
     354        devman_log_info("Function `%s' added to class `%s' as `%s'.\n",
     355            fun->pathname, class_name, class_info->dev_name);
    351356
    352357        async_answer_0(callid, EOK);
    353358}
     
    362367        driver_t *driver = (driver_t *) drv;
    363368       
    364369        initialize_running_driver(driver, &device_tree);
    365         printf(NAME ": the %s driver was successfully initialized. \n",
     370        devman_log_debug("The `%s` driver was successfully initialized.\n",
    366371            driver->name);
    367372        return 0;
    368373}
     
    384389         */
    385390        fid_t fid = fibril_create(init_running_drv, driver);
    386391        if (fid == 0) {
    387                 printf(NAME ": Error creating fibril for the initialization of "
    388                     "the newly registered running driver.\n");
     392                devman_log_error("Failed to create initialization fibril " \
     393                    "for driver `%s' .\n", driver->name);
    389394                return;
    390395        }
    391396        fibril_add_ready(fid);
     
    477482                dev = fun->dev;
    478483
    479484        if (fun == NULL && dev == NULL) {
    480                 printf(NAME ": devman_forward error - no device or function with "
    481                     "handle %" PRIun " was found.\n", handle);
     485                devman_log_error("IPC forwarding failed - " \
     486                    "no device or function with handle " \
     487                    "%" PRIun " was found.\n", handle);
    482488                async_answer_0(iid, ENOENT);
    483489                return;
    484490        }
    485491
    486492        if (fun == NULL && !drv_to_parent) {
    487                 printf(NAME ": devman_forward error - cannot connect to "
    488                     "handle %" PRIun ", refers to a device.\n", handle);
     493                devman_log_error("IPC forwarding refused - " \
     494                    "cannot connect to handle " \
     495                    "%" PRIun " (refers to a device).\n", handle);
    489496                async_answer_0(iid, ENOENT);
    490497                return;
    491498        }
     
    506513        }
    507514       
    508515        if (driver == NULL) {
    509                 printf(NAME ": devman_forward error - the device is not in %" PRIun
    510                     " usable state.\n", handle);
     516                devman_log_error("IPC forwarding refused - " \
     517                    "the device %" PRIun " is not in usable state.\n", handle);
    511518                async_answer_0(iid, ENOENT);
    512519                return;
    513520        }
     
    519526                method = DRIVER_CLIENT;
    520527       
    521528        if (driver->phone <= 0) {
    522                 printf(NAME ": devman_forward: cound not forward to driver %s ",
    523                     driver->name);
    524                 printf("the driver's phone is %" PRIun ").\n", driver->phone);
     529                devman_log_error(
     530                    "Could not forward to driver `%s' (phone is %d).\n",
     531                    driver->name, (int) driver->phone);
    525532                async_answer_0(iid, EINVAL);
    526533                return;
    527534        }
    528535
    529536        if (fun != NULL) {
    530                 printf(NAME ": devman_forward: forward connection to function %s to "
    531                     "driver %s.\n", fun->pathname, driver->name);
     537                devman_log_debug(
     538                    "Forwarding request for `%s' function to driver `%s'.\n",
     539                    fun->pathname, driver->name);
    532540        } else {
    533                 printf(NAME ": devman_forward: forward connection to device %s to "
    534                     "driver %s.\n", dev->pfun->pathname, driver->name);
     541                devman_log_debug(
     542                    "Forwarding request for `%s' device to driver `%s'.\n",
     543                    dev->pfun->pathname, driver->name);
    535544        }
    536545
    537546        async_forward_fast(iid, driver->phone, method, fwd_h, 0, IPC_FF_NONE);
     
    563572       
    564573        async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
    565574            IPC_FF_NONE);
    566         printf(NAME ": devman_connection_devmapper: forwarded connection to "
    567             "device %s to driver %s.\n", fun->pathname, dev->drv->name);
     575        devman_log_debug(
     576            "Forwarding devmapper request for `%s' function to driver `%s'.\n",
     577            fun->pathname, dev->drv->name);
    568578}
    569579
    570580/** Function for handling connections to device manager. */
     
    599609/** Initialize device manager internal structures. */
    600610static bool devman_init(void)
    601611{
    602         printf(NAME ": devman_init - looking for available drivers.\n");
     612        devman_log_debug("devman_init - looking for available drivers.\n");
    603613       
    604614        /* Initialize list of available drivers. */
    605615        init_driver_list(&drivers_list);
    606616        if (lookup_available_drivers(&drivers_list,
    607617            DRIVER_DEFAULT_STORE) == 0) {
    608                 printf(NAME " no drivers found.");
     618                devman_log_error("no drivers found.");
    609619                return false;
    610620        }
    611621
    612         printf(NAME ": devman_init - list of drivers has been initialized.\n");
     622        devman_log_debug("devman_init - list of drivers has been initialized.\n");
    613623
    614624        /* Create root device node. */
    615625        if (!init_device_tree(&device_tree, &drivers_list)) {
    616                 printf(NAME " failed to initialize device tree.");
     626                devman_log_error("Failed to initialize device tree.");
    617627                return false;
    618628        }
    619629
     
    634644{
    635645        printf(NAME ": HelenOS Device Manager\n");
    636646
     647        devman_log_init(DEVMAN_LOG_LEVEL_INFO);
     648
    637649        if (!devman_init()) {
    638                 printf(NAME ": Error while initializing service\n");
     650                devman_log_error("Error while initializing service.\n");
    639651                return -1;
    640652        }
    641653       
     
    643655        async_set_client_connection(devman_connection);
    644656
    645657        /* Register device manager at naming service. */
    646         if (service_register(SERVICE_DEVMAN) != EOK)
     658        if (service_register(SERVICE_DEVMAN) != EOK) {
     659                devman_log_error("Failed registering as a service.\n");
    647660                return -1;
     661        }
    648662
    649         printf(NAME ": Accepting connections\n");
     663        printf(NAME ": Accepting connections.\n");
    650664        async_manager();
    651665
    652666        /* Never reached. */