summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2024-01-19 18:26:34 +0100
committerTomas Bzatek <tbzatek@redhat.com>2024-01-19 18:26:34 +0100
commita55d09bb2d74944b7ea5a7e81b7d3e86bc04cd42 (patch)
tree7b2229b1fce0b342d1968069eae98a3be4afc3a8
parente9036281ebb3a5be97e42f56667bb8dfebc5b4fe (diff)
downloadtuxcmd-modules-a55d09bb2d74944b7ea5a7e81b7d3e86bc04cd42.tar.xz
common: Logging rework
Use common logging macros for a consistent output. A logging domain needs to be set in a Makefile first (the _LOG_DOMAIN define). Heavy debugging output is guarded by the __DEBUG_INTERNAL define and omitted by default. Logging severity is controlled by the TUXCMD_DEBUG env. var, typically set by the tuxcmd process itself.
-rw-r--r--common/filelist-vfs-intf.c41
-rw-r--r--common/filelist.c65
-rw-r--r--common/logutils.c37
-rw-r--r--common/logutils.h55
-rw-r--r--common/strutils.c13
-rw-r--r--common/strutils.h9
-rw-r--r--common/vfsutils.c1
7 files changed, 153 insertions, 68 deletions
diff --git a/common/filelist-vfs-intf.c b/common/filelist-vfs-intf.c
index afb7a85..9517084 100644
--- a/common/filelist-vfs-intf.c
+++ b/common/filelist-vfs-intf.c
@@ -24,6 +24,7 @@
#include "tuxcmd-vfs.h"
#include "strutils.h"
+#include "logutils.h"
#include "vfsutils.h"
#include "filelist.h"
#include "filelist-vfs-intf.h"
@@ -39,8 +40,6 @@ vfs_filelist_new (struct PathTree *files)
struct VfsFilelistData * data;
data = g_malloc0 (sizeof (struct VfsFilelistData));
-
- log ("vfs_filelist_new()\n");
data->files = files;
return data;
@@ -49,10 +48,8 @@ vfs_filelist_new (struct PathTree *files)
void
vfs_filelist_free (struct VfsFilelistData *data)
{
- if (! data) {
- fprintf (stderr, "vfs_filelist_free: data == NULL !\n");
+ if (data == NULL)
return;
- }
g_free (data->list_dir_path);
g_free (data);
}
@@ -75,7 +72,7 @@ internal_get_dir_size (struct VfsFilelistData *data, struct PathTree *tree)
if (data->break_get_dir_size)
break;
if (n->data) {
- log ("internal_get_dir_size: found item '%s', size = %zd \n", n->node, n->data->iSize);
+ log_debug ("internal_get_dir_size: found item '%s', size = %zd", n->node, n->data->iSize);
Size += (n->data->ItemType == vDirectory) ? internal_get_dir_size (data, n) : n->data->iSize;
}
idx++;
@@ -97,7 +94,7 @@ vfs_filelist_get_dir_size (struct VfsFilelistData *data, const char *APath)
if (node) {
return internal_get_dir_size (data, node);
} else {
- printf ("(EE) VFSGetDirSize: path '%s' not found\n", APath);
+ log_error ("VFSGetDirSize: path '%s' not found", APath);
return 0;
}
}
@@ -142,20 +139,20 @@ vfs_filelist_file_info (struct VfsFilelistData *data, const char *AFileName, gbo
node = filelist_tree_find_node_by_path (data->files, AFileName);
if (node) {
if (node->data) {
- printf ("(II) vfs_filelist_file_info: found file: '%s'\n", node->node);
+ log_debug ("vfs_filelist_file_info: found file: '%s'", node->node);
return assign_file_info (node, AFileName, FollowSymlinks, AddFullPath);
} else {
- printf ("(EE) vfs_filelist_file_info: node->data == NULL! \n");
+ log_error ("vfs_filelist_file_info: node->data == NULL!");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, "node->data == NULL");
return NULL;
}
} else {
- printf ("(EE) vfs_filelist_file_info: file specified not found\n");
+ log_error ("vfs_filelist_file_info: file specified not found");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "File specified not found.");
return NULL;
}
} else {
- printf ("(EE) vfs_filelist_file_info: Invalid pointers to data objects.\n");
+ log_error ("vfs_filelist_file_info: Invalid pointers to data objects.");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Invalid pointers to data objects.");
return NULL;
}
@@ -172,7 +169,7 @@ vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, gboolea
data->list_dir_node = NULL;
if (sDir == NULL) {
- printf ("(EE) vfs_filelist_list_first: sDir is NULL!\n");
+ log_error ("vfs_filelist_list_first: sDir is NULL!");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "NewPath is NULL");
return NULL;
}
@@ -192,14 +189,14 @@ vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, gboolea
full_path = g_build_filename (sDir, node->data->FName, NULL);
Item = assign_file_info (node, full_path, FollowSymlinks, AddFullPath);
g_free (full_path);
- printf ("(II) vfs_filelist_list_first: found file: %s\n", Item->FName);
+ log_debug ("vfs_filelist_list_first: found file: %s", Item->FName);
return Item;
} else {
- printf ("(II) vfs_filelist_list_first: no more files\n");
+ log_debug ("vfs_filelist_list_first: no more files");
return NULL;
}
} else {
- printf ("(EE) vfs_filelist_list_first: Directory '%s' not found.\n", sDir);
+ log_error ("vfs_filelist_list_first: Directory '%s' not found.", sDir);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Directory '%s' not found.", sDir);
return NULL;
}
@@ -214,7 +211,7 @@ vfs_filelist_list_next (struct VfsFilelistData *data, GError **error)
full_path = NULL;
if (! data->list_dir_node) {
- printf ("(EE) vfs_filelist_list_next: data->list_dir_node is NULL!\n");
+ log_error ("vfs_filelist_list_next: data->list_dir_node is NULL!");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, "data->list_dir_node is NULL");
return NULL;
}
@@ -226,10 +223,10 @@ vfs_filelist_list_next (struct VfsFilelistData *data, GError **error)
full_path = g_build_filename (data->list_dir_path, node->data->FName, NULL);
Item = assign_file_info (node, full_path, data->follow_symlinks, data->add_full_path);
g_free (full_path);
- printf ("(II) vfs_filelist_list_next: found file: %s\n", Item->FName);
+ log_debug ("vfs_filelist_list_next: found file: %s", Item->FName);
return Item;
} else {
- printf ("(II) vfs_filelist_list_next: no more files\n");
+ log_debug ("vfs_filelist_list_next: no more files");
return NULL;
}
}
@@ -253,23 +250,23 @@ vfs_filelist_change_dir (struct VfsFilelistData *data, const char *NewPath, GErr
char *ANewPath;
if (NewPath == NULL) {
- printf ("(EE) VFSChangeDir: NewPath is NULL!\n");
+ log_error ("VFSChangeDir: NewPath is NULL!");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "NewPath is NULL");
return NULL;
}
/* make up the target path */
- printf ("(--) VFSChangeDir: Going to change dir from '%s'\n", NewPath);
+ log_debug ("VFSChangeDir: Going to change dir from '%s'", NewPath);
ANewPath = exclude_trailing_path_sep (NewPath);
if (! ANewPath || strlen (ANewPath) <= 0)
ANewPath = g_strdup ("/");
- printf ("(--) VFSChangeDir: Going to change dir to '%s'\n", ANewPath);
+ log_debug ("VFSChangeDir: Going to change dir to '%s'", ANewPath);
/* find the directory in the filelist */
if (filelist_tree_find_node_by_path (data->files, ANewPath)) {
return ANewPath;
} else {
- printf ("(EE) VFSChangeDir: Directory '%s' not found.\n", ANewPath);
+ log_error ("VFSChangeDir: Directory '%s' not found.", ANewPath);
g_free (ANewPath);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Directory '%s' not found.", ANewPath);
return NULL;
diff --git a/common/filelist.c b/common/filelist.c
index 2926376..023668d 100644
--- a/common/filelist.c
+++ b/common/filelist.c
@@ -23,6 +23,7 @@
#include "filelist.h"
#include "strutils.h"
+#include "logutils.h"
#include "vfsutils.h"
@@ -32,8 +33,9 @@ filelist_tree_new ()
{
struct PathTree *tree;
+ log_debug ("filelist_tree_new()");
+
tree = g_malloc0 (sizeof (struct PathTree));
- log ("filelist_tree_new()\n");
tree->items = g_ptr_array_new ();
tree->data = NULL;
tree->original_index = 0;
@@ -51,10 +53,8 @@ filelist_tree_free (struct PathTree *tree)
{
int i;
- if (! tree) {
- fprintf (stderr, "filelist_tree_free: tree == NULL !\n");
+ if (tree == NULL)
return;
- }
if (tree->items && tree->items->len > 0) {
for (i = 0; i < tree->items->len; i++)
@@ -80,7 +80,7 @@ filelist_tree_print_recurr (struct PathTree *tree, unsigned int level)
if (tree) {
fill = g_strnfill (level * 2, 32);
- g_print (" %s#%lu. \"%s\"\n", fill, tree->original_index, tree->node);
+ g_print (" %s[%lu] '%s'\n", fill, tree->original_index, tree->node);
if (tree->items && tree->items->len > 0)
for (i = 0; i < tree->items->len; i++) {
@@ -94,7 +94,10 @@ filelist_tree_print_recurr (struct PathTree *tree, unsigned int level)
void
filelist_tree_print (struct PathTree *tree)
{
+ if (_log_level < LOG_INFO)
+ return;
filelist_tree_print_recurr (tree, 0);
+ g_print ("\n");
}
@@ -115,17 +118,17 @@ filelist_tree_find_node_by_path (struct PathTree *tree, const char *path)
path += 2;
/* remove leading and trailing '/' if present */
p = exclude_trailing_path_sep (path + G_IS_DIR_SEPARATOR (*path));
- log (" filelist_tree_find_node_by_path: path = '%s', p = '%s'\n", path, p);
+ log_debug (" filelist_tree_find_node_by_path: path = '%s', p = '%s'", path, p);
node = NULL;
if (tree && tree->node && g_strcmp0 (tree->node, "/") == 0 && g_strcmp0 (path, "/") == 0) {
- log (" filelist_tree_find_node_by_path: matched root '/' element, returning.\n");
+ log_debug (" filelist_tree_find_node_by_path: matched root '/' element, returning.");
node = tree;
} else
if (tree && tree->items && tree->items->len > 0) {
split_path (p, &first_part, &last_part);
- log (" filelist_tree_find_node_by_path: first_part = '%s'\n", first_part);
- log (" filelist_tree_find_node_by_path: last_part = '%s'\n", last_part);
+ log_debug (" filelist_tree_find_node_by_path: first_part = '%s'", first_part);
+ log_debug (" filelist_tree_find_node_by_path: last_part = '%s'", last_part);
/* find existing node */
for (i = 0; i < tree->items->len; i++) {
@@ -134,16 +137,16 @@ filelist_tree_find_node_by_path (struct PathTree *tree, const char *path)
/* this is the final station */
if (! last_part) {
node = t;
- log (" filelist_tree_find_node_by_path: found final node '%s', returning.\n", t->node);
+ log_debug (" filelist_tree_find_node_by_path: found final node '%s', returning.", t->node);
} else
/* recurse to child items */
if (t->items && last_part) {
- log (" filelist_tree_find_node_by_path: found node '%s', recursing in deep.\n", t->node);
+ log_debug (" filelist_tree_find_node_by_path: found node '%s', recursing in deep.", t->node);
node = filelist_tree_find_node_by_path (t, last_part);
} else {
/* item found but no subitems */
- log (" filelist_tree_find_node_by_path: found node '%s', but no subitems found.\n", t->node);
+ log_debug (" filelist_tree_find_node_by_path: found node '%s', but no subitems found.", t->node);
}
break;
@@ -178,12 +181,12 @@ filelist_tree_add_item_recurr (struct PathTree *tree, const char *path, struct T
unsigned int i;
split_path (path, &first_part, &last_part);
- log (" filelist_tree_add_item_recur: first_part = '%s'\n", first_part);
- log (" filelist_tree_add_item_recur: last_part = '%s'\n", last_part);
+ log_debug (" filelist_tree_add_item_recur: first_part = '%s'", first_part);
+ log_debug (" filelist_tree_add_item_recur: last_part = '%s'", last_part);
if (last_part == NULL) {
/* final destination, create new item here */
- log (" filelist_tree_add_item_recur: creating new item here.\n");
+ log_debug (" filelist_tree_add_item_recur: creating new item here.");
t = g_malloc0 (sizeof (struct PathTree));
t->items = NULL;
t->data = item;
@@ -202,7 +205,7 @@ filelist_tree_add_item_recurr (struct PathTree *tree, const char *path, struct T
g_ptr_array_add (tree->items, t);
} else {
/* not a final place, find parent node or create new one if doesn't exist */
- log (" filelist_tree_add_item_recur: node '%s', path '%s'\n", tree->node, path);
+ log_debug (" filelist_tree_add_item_recur: node '%s', path '%s'", tree->node, path);
if (! tree->items)
tree->items = g_ptr_array_new ();
@@ -211,7 +214,7 @@ filelist_tree_add_item_recurr (struct PathTree *tree, const char *path, struct T
for (i = 0; i < tree->items->len; i++) {
t = g_ptr_array_index (tree->items, i);
if (g_strcmp0 (t->node, first_part) == 0) {
- log (" filelist_tree_add_item_recur: found node '%s'\n", t->node);
+ log_debug (" filelist_tree_add_item_recur: found node '%s'", t->node);
node = t;
break;
}
@@ -219,7 +222,7 @@ filelist_tree_add_item_recurr (struct PathTree *tree, const char *path, struct T
if (node == NULL) {
/* create new path holder node */
- log (" filelist_tree_add_item_recur: parent node not found, creating new path holder\n");
+ log_debug (" filelist_tree_add_item_recur: parent node not found, creating new path holder");
node = g_malloc0 (sizeof (struct PathTree));
node->items = g_ptr_array_new ();
node->node = g_strdup (first_part);
@@ -247,16 +250,16 @@ filelist_tree_add_item (struct PathTree *tree, const char *path, struct TVFSItem
struct PathTree *found;
if (! tree) {
- fprintf (stderr, "filelist_tree_add_item: tree == NULL !\n");
+ log_error ("filelist_tree_add_item: tree == NULL!");
return FALSE;
}
if (! path) {
- fprintf (stderr, "filelist_tree_add_item: path == NULL !\n");
+ log_error ("filelist_tree_add_item: path == NULL!");
return FALSE;
}
if (g_strcmp0 (path, "/") == 0 || g_strcmp0 (path, ".") == 0 || g_strcmp0 (path, "..") == 0 || g_strcmp0 (path, "./") == 0) {
- fprintf (stderr, "filelist_tree_add_item: path '%s' is not a valid path\n", path);
+ log_error ("filelist_tree_add_item: path '%s' is not a valid path", path);
return FALSE;
}
@@ -266,7 +269,7 @@ filelist_tree_add_item (struct PathTree *tree, const char *path, struct TVFSItem
/* remove leading and trailing '/' if present */
p = exclude_trailing_path_sep (path + G_IS_DIR_SEPARATOR (*path));
- log (" filelist_tree_add_item: p = '%s'\n", p);
+ log_debug (" filelist_tree_add_item: p = '%s'", p);
pp = canonicalize_filename (p);
if (! pp)
@@ -275,7 +278,7 @@ filelist_tree_add_item (struct PathTree *tree, const char *path, struct TVFSItem
found = filelist_tree_find_node_by_path (tree, pp);
if (found) {
/* replace old data with current ones (record might have been created automatically during path building) */
- log (" filelist_tree_add_item: found old item, replacing data\n");
+ log_debug (" filelist_tree_add_item: found old item, replacing data");
found->original_index = original_index;
/* free old data */
free_vfs_item (found->data);
@@ -320,7 +323,7 @@ resolve_symlink_recurr (struct PathTree *node, struct PathTree *root_tree, const
struct PathTree *link_t;
rel = resolve_relative (path, link_dest);
- g_print (" resolve_symlink_recurr: relative = '%s'\n", rel);
+ log_debug (" resolve_symlink_recurr: relative = '%s'", rel);
if (rel) {
link_t = filelist_tree_find_node_by_path (root_tree, rel);
if (link_t && link_t->data) {
@@ -329,21 +332,21 @@ resolve_symlink_recurr (struct PathTree *node, struct PathTree *root_tree, const
new_path = g_path_get_dirname (rel);
if (level > FILELIST_MAX_SYMLINK_DEPTH || ! new_path) {
node->symlink_target_data = link_t->data;
- g_print (" resolve_symlink_recurr: max depth reached, link is broken. new_path = '%s'\n", new_path);
+ log_debug (" resolve_symlink_recurr: max depth reached, link is broken. new_path = '%s'", new_path);
} else {
- g_print (" resolve_symlink_recurr: going deep, rel = '%s', new_path = '%s'\n", rel, new_path);
+ log_debug (" resolve_symlink_recurr: going deep, rel = '%s', new_path = '%s'", rel, new_path);
resolve_symlink_recurr (node, root_tree, new_path, link_t->data->sLinkTo, level + 1);
}
g_free (new_path);
} else {
/* final destination */
node->symlink_target_data = link_t->data;
- g_print (" resolve_symlink_recurr: reached target '%s'\n", rel);
+ log_debug (" resolve_symlink_recurr: reached target '%s'", rel);
}
} else {
/* target not found, link is broken */
node->symlink_target_data = NULL;
- g_print (" resolve_symlink_recurr: target '%s' not found, link is broken\n", rel);
+ log_debug (" resolve_symlink_recurr: target '%s' not found, link is broken", rel);
}
}
g_free (rel);
@@ -361,7 +364,7 @@ filelist_tree_resolve_symlinks_recurr (struct PathTree *tree, struct PathTree *r
t = g_ptr_array_index (tree->items, i);
if (t && t->data && t->data->IsLink && t->data->sLinkTo) {
- g_print ("filelist_tree_resolve_symlinks: found '%s/%s' --> '%s', resolving...\n", path, t->node, t->data->sLinkTo);
+ log_debug ("filelist_tree_resolve_symlinks: found '%s/%s' --> '%s', resolving...", path, t->node, t->data->sLinkTo);
resolve_symlink_recurr (t, root_tree, path, t->data->sLinkTo, 1);
}
new_path = g_build_filename (path, t->node, NULL);
@@ -374,7 +377,7 @@ filelist_tree_resolve_symlinks_recurr (struct PathTree *tree, struct PathTree *r
void
filelist_tree_resolve_symlinks (struct PathTree *tree)
{
- log ("filelist_tree_resolve_symlinks: begin\n");
+ log_debug ("filelist_tree_resolve_symlinks: begin");
filelist_tree_resolve_symlinks_recurr (tree, tree, "/");
- log ("filelist_tree_resolve_symlinks: end\n");
+ log_debug ("filelist_tree_resolve_symlinks: end");
}
diff --git a/common/logutils.c b/common/logutils.c
new file mode 100644
index 0000000..1913954
--- /dev/null
+++ b/common/logutils.c
@@ -0,0 +1,37 @@
+/* Tux Commander VFS: Logging utilities
+ * Copyright (C) 2023-2024 Tomas Bzatek <tbzatek@users.sourceforge.net>
+ * Check for updates on tuxcmd.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <string.h>
+#include <glib.h>
+
+#include "logutils.h"
+
+int _log_level = LOG_NOTICE;
+
+
+void
+log_init (void)
+{
+ char *d;
+
+ d = getenv ("TUXCMD_DEBUG");
+ if (d && strlen (d) > 0)
+ /* TODO: might wanna distinguish log level value in the future */
+ _log_level = LOG_DEBUG;
+}
diff --git a/common/logutils.h b/common/logutils.h
new file mode 100644
index 0000000..2e67f04
--- /dev/null
+++ b/common/logutils.h
@@ -0,0 +1,55 @@
+/* Tux Commander VFS: Logging utilities
+ * Copyright (C) 2023-2024 Tomas Bzatek <tbzatek@users.sourceforge.net>
+ * Check for updates on tuxcmd.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __LOGUTILS_H__
+#define __LOGUTILS_H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include <stdio.h>
+#include <syslog.h>
+
+
+extern int _log_level;
+
+#define _log(severity, prefix, format, ...) { \
+ if (_log_level >= severity) \
+ fprintf (stdout, " " prefix " " format "\n", ##__VA_ARGS__); \
+}
+
+#define log_error(format, msg...) _log (LOG_ERR, "(EE::" G_STRINGIFY (_LOG_DOMAIN) ")", format, ##msg)
+#define log_warn(format, msg...) _log (LOG_WARNING, "(WW::" G_STRINGIFY (_LOG_DOMAIN) ")", format, ##msg)
+#define log_notice(format, msg...) _log (LOG_NOTICE, "(II::" G_STRINGIFY (_LOG_DOMAIN) ")", format, ##msg)
+#define log_info(format, msg...) _log (LOG_INFO, " (--)", format, ##msg)
+
+#ifdef __DEBUG_INTERNAL
+ #define log_debug(format, msg...) _log (LOG_DEBUG, " ", format, ##msg)
+#else
+ #define log_debug(format, msg...) { }
+#endif
+
+void log_init (void);
+
+
+#ifdef __cplusplus
+ }
+#endif
+#endif /* __LOGUTILS_H__ */
diff --git a/common/strutils.c b/common/strutils.c
index 3b0a1db..a877c2e 100644
--- a/common/strutils.c
+++ b/common/strutils.c
@@ -18,10 +18,11 @@
*/
#include <string.h>
+#include <syslog.h>
#include <glib.h>
#include "strutils.h"
-
+#include "logutils.h"
char *
@@ -85,9 +86,9 @@ resolve_relative (const char *source, const char *point_to)
return g_strdup (point_to);
rel = g_build_filename (source, point_to, NULL);
- log ("resolve_relative: rel = '%s'\n", rel);
+ log_debug ("resolve_relative: rel = '%s'", rel);
canon = canonicalize_filename (rel);
- log ("resolve_relative: canon = '%s'\n", canon);
+ log_debug ("resolve_relative: canon = '%s'", canon);
g_free (rel);
return canon;
@@ -214,7 +215,7 @@ wide_to_utf8 (const wchar_t *src)
if (ch < 0x80) /* 0x00-0x7f: 1 byte */
{
if (!len--) {
- log ("wide_to_utf8: error converting input string, overflow.\n");
+ log_debug ("wide_to_utf8: error converting input string, overflow.");
break; /* overflow */
}
*dst++ = ch;
@@ -224,7 +225,7 @@ wide_to_utf8 (const wchar_t *src)
if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
{
if ((len -= 2) < 0) {
- log ("wide_to_utf8: error converting input string, overflow.\n");
+ log_debug ("wide_to_utf8: error converting input string, overflow.");
break; /* overflow */
}
dst[1] = 0x80 | (ch & 0x3f);
@@ -236,7 +237,7 @@ wide_to_utf8 (const wchar_t *src)
/* 0x800-0xffff: 3 bytes */
if ((len -= 3) < 0) {
- log ("wide_to_utf8: error converting input string, overflow.\n");
+ log_debug ("wide_to_utf8: error converting input string, overflow.");
break; /* overflow */
}
dst[2] = 0x80 | (ch & 0x3f);
diff --git a/common/strutils.h b/common/strutils.h
index 7fed4c5..791d387 100644
--- a/common/strutils.h
+++ b/common/strutils.h
@@ -24,15 +24,6 @@
extern "C" {
#endif
-
-#ifdef __VERBOSE_DEBUG
- #define log(msg...) g_print(msg)
-#else
- #define log(msg...) { }
-#endif
-
-
-
/* path manipulating functions, all return newly allocated string */
char * include_trailing_path_sep (const char *APath);
char * exclude_trailing_path_sep (const char *APath);
diff --git a/common/vfsutils.c b/common/vfsutils.c
index 856d9f9..e38d5dd 100644
--- a/common/vfsutils.c
+++ b/common/vfsutils.c
@@ -23,6 +23,7 @@
#include <glib.h>
#include "strutils.h"
+#include "logutils.h"
#include "tuxcmd-vfs.h"