Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision ff244e6b3c292cefe297c5e3d258f40aa520583d)
+++ uspace/drv/usbhid/main.c	(revision 9e7cdf8cec0b341b659dd28789769d5dc4ebb7b7)
@@ -49,4 +49,5 @@
 #include <usb/devreq.h>
 #include <usb/descriptor.h>
+#include <usb/debug.h>
 #include <io/console.h>
 #include "hid.h"
@@ -196,7 +197,7 @@
 	}
 /*
-	printf("type: %d\n", type);
-	printf("mods: 0x%x\n", mods);
-	printf("keycode: %u\n", key);
+	usb_log_debug2("type: %d\n", type);
+	usb_log_debug2("mods: 0x%x\n", mods);
+	usb_log_debug2("keycode: %u\n", key);
 */
 	
@@ -228,5 +229,5 @@
 	ev.c = layout[active_layout]->parse_ev(&ev);
 
-	printf("Sending key %d to the console\n", ev.key);
+	usb_log_debug("Sending key %d to the console\n", ev.key);
 	assert(console_callback_phone != -1);
 	async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c);
@@ -249,15 +250,13 @@
     uint8_t modifiers, void *arg)
 {
-	printf("Got keys: ");
+	usb_log_debug2("Got keys from parser: ");
 	unsigned i;
 	for (i = 0; i < count; ++i) {
-		printf("%d ", key_codes[i]);
+		usb_log_debug2("%d ", key_codes[i]);
 		// TODO: Key press / release
-
-		// TODO: NOT WORKING
 		unsigned int key = usbkbd_parse_scancode(key_codes[i]);
 		kbd_push_ev(KEY_PRESS, key);
 	}
-	printf("\n");
+	usb_log_debug2("\n");
 }
 
@@ -339,5 +338,5 @@
 	free(descriptors);
 	if (rc != EOK) {
-		printf("Problem with parsing standard descriptors.\n");
+		usb_log_warning("Problem with parsing standard descriptors.\n");
 		return rc;
 	}
@@ -346,5 +345,5 @@
 	rc = usbkbd_get_report_descriptor(kbd_dev);
 	if (rc != EOK) {
-		printf("Problem with parsing HID REPORT descriptor.\n");
+		usb_log_warning("Problem with parsing REPORT descriptor.\n");
 		return rc;
 	}
@@ -356,7 +355,7 @@
 	 * 1) select one configuration (lets say the first)
 	 * 2) how many interfaces?? how to select one??
-     *    ("The default setting for an interface is always alternate setting zero.")
+	 *    ("The default setting for an interface is always alternate setting zero.")
 	 * 3) find endpoint which is IN and INTERRUPT (parse), save its number
-     *    as the endpoint for polling
+	 *    as the endpoint for polling
 	 */
 	
@@ -370,5 +369,5 @@
 
 	if (kbd_dev == NULL) {
-		fprintf(stderr, NAME ": No memory!\n");
+		usb_log_fatal("No memory!\n");
 		return NULL;
 	}
@@ -380,5 +379,5 @@
 	int rc = kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0);
 	if (rc < 0) {
-		printf("Problem setting phone to HC.\n");
+		usb_log_error("Problem setting phone to HC.\n");
 		goto error_leave;
 	}
@@ -386,5 +385,5 @@
 	rc = kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, dev);
 	if (rc < 0) {
-		printf("Problem getting address of the device.\n");
+		usb_log_error("Problem getting address of the device.\n");
 		goto error_leave;
 	}
@@ -392,5 +391,5 @@
 	// doesn't matter now that we have no address
 //	if (kbd_dev->address < 0) {
-//		fprintf(stderr, NAME ": No device address!\n");
+//		usb_log_error("No device address!\n");
 //		free(kbd_dev);
 //		return NULL;
@@ -407,6 +406,4 @@
 	usbkbd_process_descriptors(kbd_dev);
 
-
-
 	/*
 	 * Initialize the backing connection to the host controller.
@@ -414,6 +411,6 @@
 	rc = usb_device_connection_initialize_from_device(&kbd_dev->wire, dev);
 	if (rc != EOK) {
-		printf("Problem initializing connection to device: %s.\n",
-		    str_error(rc));
+		usb_log_error("Problem initializing connection to device: %s."
+		    "\n", str_error(rc));
 		goto error_leave;
 	}
@@ -425,5 +422,5 @@
 	    GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN);
 	if (rc != EOK) {
-		printf("Failed to initialize interrupt in pipe: %s.\n",
+		usb_log_error("Failed to initialize interrupt in pipe: %s.\n",
 		    str_error(rc));
 		goto error_leave;
@@ -448,11 +445,13 @@
 	//usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 
 	//    NULL);
-	printf("Calling usb_hid_boot_keyboard_input_report() with size %zu\n",
-	    actual_size);
+	/*usb_log_debug2("Calling usb_hid_boot_keyboard_input_report() with size"
+	    " %zu\n", actual_size);*/
 	//dump_buffer("bufffer: ", buffer, actual_size);
-	int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, 
-	    NULL);
-	if (rc != EOK) {
-		printf("Error in usb_hid_boot_keyboard_input_report(): %d\n", rc);
+	int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,
+	    callbacks, NULL);
+	
+	if (rc != EOK) {
+		usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
+		    "%s\n", str_error(rc));
 	}
 }
@@ -464,5 +463,5 @@
 	size_t actual_size;
 
-	printf("Polling keyboard...\n");
+	usb_log_info("Polling keyboard...\n");
 
 	while (true) {
@@ -471,5 +470,5 @@
 		sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe);
 		if (sess_rc != EOK) {
-			printf("Failed to start a session: %s.\n",
+			usb_log_warning("Failed to start a session: %s.\n",
 			    str_error(sess_rc));
 			continue;
@@ -481,5 +480,5 @@
 
 		if (rc != EOK) {
-			printf("Error polling the keyboard: %s.\n",
+			usb_log_warning("Error polling the keyboard: %s.\n",
 			    str_error(rc));
 			continue;
@@ -487,5 +486,5 @@
 
 		if (sess_rc != EOK) {
-			printf("Error closing session: %s.\n",
+			usb_log_warning("Error closing session: %s.\n",
 			    str_error(sess_rc));
 			continue;
@@ -497,5 +496,5 @@
 		 */
 		if (actual_size == 0) {
-			printf("Keyboard returned NAK\n");
+			usb_log_debug("Keyboard returned NAK\n");
 			continue;
 		}
@@ -504,5 +503,5 @@
 		 * TODO: Process pressed keys.
 		 */
-		printf("Calling usbkbd_process_interrupt_in()\n");
+		usb_log_debug("Calling usbkbd_process_interrupt_in()\n");
 		usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size);
 	}
@@ -514,8 +513,6 @@
 static int usbkbd_fibril_device(void *arg)
 {
-	printf("!!! USB device fibril\n");
-
 	if (arg == NULL) {
-		printf("No device!\n");
+		usb_log_error("No device!\n");
 		return -1;
 	}
@@ -526,5 +523,5 @@
 	usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev);
 	if (kbd_dev == NULL) {
-		printf("Error while initializing device.\n");
+		usb_log_error("Error while initializing device.\n");
 		return -1;
 	}
@@ -561,5 +558,5 @@
 	fid_t fid = fibril_create(usbkbd_fibril_device, dev);
 	if (fid == 0) {
-		printf("%s: failed to start fibril for HID device\n", NAME);
+		usb_log_error("Failed to start fibril for HID device\n");
 		return ENOMEM;
 	}
@@ -587,4 +584,5 @@
 int main(int argc, char *argv[])
 {
+	usb_log_enable(USB_LOG_LEVEL_MAX, NAME);
 	return driver_main(&kbd_driver);
 }
