diff options
author | Akira TAGOH <akira@tagoh.org> | 2006-10-21 19:29:43 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2006-10-21 19:29:43 +0000 |
commit | f6dfc9c6c80ba6b65e18edc858b37c9a670e2dde (patch) | |
tree | f208132017e91835465350a8866956dcc0beab63 | |
parent | b9cf605d8fe87e71e2b4870ba528154ac7e2b5c9 (diff) |
2006-10-22 Akira TAGOH <at@gclab.org>
* hieroglyph/Makefile.am (libhieroglyph_la_SOURCES): added hglog.c.
* hieroglyph/hglog.[ch]: new files for logger.
35 files changed, 594 insertions, 276 deletions
@@ -1,3 +1,9 @@ +2006-10-22 Akira TAGOH <at@gclab.org> + + * hieroglyph/Makefile.am (libhieroglyph_la_SOURCES): added hglog.c. + + * hieroglyph/hglog.[ch]: new files for logger. + 2006-10-21 Akira TAGOH <at@gclab.org> * hieroglyph/vm.c (_hg_vm_op_rollbacksecuritylevel): ignore the errors. diff --git a/devices/cairo/cairo-ps-main.c b/devices/cairo/cairo-ps-main.c index 0c75071..32412d2 100644 --- a/devices/cairo/cairo-ps-main.c +++ b/devices/cairo/cairo-ps-main.c @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * cairo-ps-main.c - * Copyright (C) 2005 Akira TAGOH + * Copyright (C) 2005,2006 Akira TAGOH * * Authors: * Akira TAGOH <at@gclab.org> @@ -29,6 +29,7 @@ #include <cairo/cairo-ps.h> #include <glib.h> #include <hieroglyph/debug.h> +#include <hieroglyph/hglog.h> #include "hgdevice-cairo.h" @@ -62,7 +63,7 @@ device_open(HgPageInfo *info) fd = g_file_open_tmp("ps-embedded-XXXXXX", &filename, NULL); if (fd == -1) { - g_warning("Failed to open a file descriptor."); + hg_log_warning("Failed to open a file descriptor."); if (filename) g_free(filename); @@ -80,7 +81,7 @@ device_open(HgPageInfo *info) cdev->u.ps.fd = fd; if (cairo_status(cdev->reference) != CAIRO_STATUS_SUCCESS) { - g_warning("Failed to create an reference of cairo."); + hg_log_warning("Failed to create an reference of cairo."); } TRACE_LEAVE; diff --git a/devices/cairo/cairo-xlib-main.c b/devices/cairo/cairo-xlib-main.c index 29dfe5a..c08e4a4 100644 --- a/devices/cairo/cairo-xlib-main.c +++ b/devices/cairo/cairo-xlib-main.c @@ -26,6 +26,7 @@ #endif #include <cairo/cairo-xlib.h> +#include <hieroglyph/hglog.h> #include "hgdevice-cairo.h" @@ -44,7 +45,7 @@ _cairo_xlib_real_set_page_size(HgCairoDevice *device, width, height); cairo_xlib_surface_set_size(device->surface, width, height); XFlush(device->u.xlib.dpy); - g_warning("%s: FIXME: implement me", __FUNCTION__); + hg_log_warning("%s: FIXME: implement me", __FUNCTION__); return TRUE; } @@ -68,7 +69,7 @@ device_open(void) cdev->u.type = HG_DEVICE_CAIRO_XLIB_SURFACE; cdev->u.xlib.dpy = XOpenDisplay(NULL); if (cdev->u.xlib.dpy == NULL) { - g_warning("Failed to open a display."); + hg_log_warning("Failed to open a display."); hg_device_destroy(dev); return NULL; } @@ -89,7 +90,7 @@ device_open(void) 400, 400); cdev->reference = cairo_create(cdev->surface); if (cairo_status(cdev->reference) != CAIRO_STATUS_SUCCESS) { - g_warning("Failed to create an reference of cairo."); + hg_log_warning("Failed to create an reference of cairo."); hg_device_destroy(dev); return NULL; } diff --git a/devices/cairo/hgdevice-cairo.c b/devices/cairo/hgdevice-cairo.c index 0761761..c8fbcee 100644 --- a/devices/cairo/hgdevice-cairo.c +++ b/devices/cairo/hgdevice-cairo.c @@ -26,6 +26,7 @@ #endif #include <hieroglyph/hgarray.h> +#include <hieroglyph/hglog.h> #include <hieroglyph/hgvaluenode.h> #include "hgdevice-cairo.h" @@ -85,7 +86,7 @@ _hg_cairo_device_print_path(HgPathNode *node) g_print("%f %f %f %f %f %f curveto\n", node->x, node->y, node->next->x, node->next->y, node->next->next->x, node->next->next->y); node = node->next->next; } else { - g_warning("[BUG] Invalid path for curve."); + hg_log_warning("[BUG] Invalid path for curve."); } break; case HG_PATH_ARC: @@ -93,7 +94,7 @@ _hg_cairo_device_print_path(HgPathNode *node) g_print("%f %f %f %f %f arc\n", node->x, node->y, node->next->x, node->next->next->x, node->next->next->y); node = node->next->next; } else { - g_warning("[BUG] Invalid path for arc."); + hg_log_warning("[BUG] Invalid path for arc."); } break; case HG_PATH_MATRIX: @@ -101,11 +102,11 @@ _hg_cairo_device_print_path(HgPathNode *node) g_print("[%f %f %f %f %f %f] matrix\n", node->x, node->y, node->next->x, node->next->y, node->next->next->x, node->next->next->y); node = node->next->next; } else { - g_warning("[BUG] Invalid matrix was given."); + hg_log_warning("[BUG] Invalid matrix was given."); } break; default: - g_warning("[BUG] Unknown path type %d was given.", node->type); + hg_log_warning("[BUG] Unknown path type %d was given.", node->type); break; } node = node->next; @@ -244,7 +245,7 @@ _hg_cairo_device_real_finalize(HgDevice *device) { HgCairoDevice *cdev = (HgCairoDevice *)device; - g_warning("%s: FIXME: implement me.", __FUNCTION__); + hg_log_warning("%s: FIXME: implement me.", __FUNCTION__); cairo_show_page(cdev->reference); XFlush(cdev->u.xlib.dpy); @@ -361,8 +362,8 @@ _hg_cairo_device_real_stroke(HgDevice *device, } else if (HG_IS_VALUE_REAL (node)) { d = HG_VALUE_GET_REAL (node); } else { - g_warning("[BUG] Invalid object type %d was given for dashline pattern.", - HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] Invalid object type %d was given for dashline pattern.", + HG_VALUE_GET_VALUE_TYPE (node)); d = 0.0; } dashes[i] = d; @@ -421,7 +422,7 @@ _hg_cairo_device_set_path(HgCairoDevice *device, node->next->next->x, node->next->next->y); node = node->next->next; } else { - g_warning("[BUG] Invalid path for curve."); + hg_log_warning("[BUG] Invalid path for curve."); retval = FALSE; } break; @@ -432,7 +433,7 @@ _hg_cairo_device_set_path(HgCairoDevice *device, node->next->next->x, node->next->next->y); node = node->next->next; } else { - g_warning("[BUG] Invalid path for arc."); + hg_log_warning("[BUG] Invalid path for arc."); retval = FALSE; } break; @@ -449,12 +450,12 @@ _hg_cairo_device_set_path(HgCairoDevice *device, cairo_set_matrix(device->reference, &trans); node = node->next->next; } else { - g_warning("[BUG] Invalid matrix was given."); + hg_log_warning("[BUG] Invalid matrix was given."); retval = FALSE; } break; default: - g_warning("[BUG] Unknown path type %d was given.", node->type); + hg_log_warning("[BUG] Unknown path type %d was given.", node->type); retval = FALSE; break; } @@ -481,7 +482,7 @@ _hg_cairo_device_set_line_cap(HgCairoDevice *device, cap = CAIRO_LINE_CAP_SQUARE; break; default: - g_warning("[BUG] Invalid linecap type %d", line_cap); + hg_log_warning("[BUG] Invalid linecap type %d", line_cap); cap = CAIRO_LINE_CAP_BUTT; break; } @@ -505,7 +506,7 @@ _hg_cairo_device_set_line_join(HgCairoDevice *device, join = CAIRO_LINE_JOIN_BEVEL; break; default: - g_warning("[BUG] Invalid linejoin type %d", line_join); + hg_log_warning("[BUG] Invalid linejoin type %d", line_join); join = CAIRO_LINE_JOIN_MITER; break; } diff --git a/hieroglyph/Makefile.am b/hieroglyph/Makefile.am index 88433ed..1d259db 100644 --- a/hieroglyph/Makefile.am +++ b/hieroglyph/Makefile.am @@ -46,6 +46,7 @@ hginclude_HEADERS = \ hggraphics.h \ hglineedit.h \ hglist.h \ + hglog.h \ hgmacros.h \ hgmatrix.h \ hgmem.h \ @@ -95,6 +96,7 @@ libhieroglyph_la_SOURCES = \ hggraphics.c \ hglineedit.c \ hglist.c \ + hglog.c \ hgmatrix.c \ hgmem.c \ hgpage.c \ diff --git a/hieroglyph/hgallocator-bfit.c b/hieroglyph/hgallocator-bfit.c index 4385e91..4ed8f91 100644 --- a/hieroglyph/hgallocator-bfit.c +++ b/hieroglyph/hgallocator-bfit.c @@ -29,6 +29,7 @@ #include <setjmp.h> #include "hgallocator-bfit.h" #include "hgallocator-private.h" +#include "hglog.h" #include "hgmem.h" #include "ibtree.h" #include "ilist.h" @@ -194,14 +195,14 @@ _hg_allocator_bfit_remove_block(HgAllocatorBFitPrivate *priv, HG_MEM_ALIGNMENT, aligned); if ((l = hg_btree_find(priv->free_block_tree, GSIZE_TO_POINTER (aligned))) == NULL) { - g_warning("[BUG] there are no memory chunks sized %" G_GSIZE_FORMAT " (aligned size: %" G_GSIZE_FORMAT ".\n", - block->length, aligned); + hg_log_warning("[BUG] there are no memory chunks sized %" G_GSIZE_FORMAT " (aligned size: %" G_GSIZE_FORMAT ".\n", + block->length, aligned); } else { HgListIter iter = hg_list_find_iter(l, block); if (iter == NULL) { - g_warning("[BUG] can't find a memory block %p (size: %" G_GSIZE_FORMAT ", aligned size: %" G_GSIZE_FORMAT ".\n", - block, block->length, aligned); + hg_log_warning("[BUG] can't find a memory block %p (size: %" G_GSIZE_FORMAT ", aligned size: %" G_GSIZE_FORMAT ".\n", + block, block->length, aligned); } else { l = hg_list_iter_delete_link(iter); if (l == NULL) { @@ -236,7 +237,7 @@ _hg_allocator_bfit_add_free_block(HgAllocatorBFitPrivate *priv, HgMemBFitBlock *b = block->prev; if (((gsize)b->heap_fragment + b->length) != (gsize)block->heap_fragment) { - g_warning("[BUG] wrong block chain detected. (block: %p heap: %p length: %" G_GSIZE_FORMAT ") is chained from (block: %p heap: %p length: %" G_GSIZE_FORMAT ")", block, block->heap_fragment, block->length, b, b->heap_fragment, b->length); + hg_log_warning("[BUG] wrong block chain detected. (block: %p heap: %p length: %" G_GSIZE_FORMAT ") is chained from (block: %p heap: %p length: %" G_GSIZE_FORMAT ")", block, block->heap_fragment, block->length, b, b->heap_fragment, b->length); break; } /* block must be removed from array because available size is increased. */ @@ -253,7 +254,7 @@ _hg_allocator_bfit_add_free_block(HgAllocatorBFitPrivate *priv, HgMemBFitBlock *b = block->next; if (((gsize)block->heap_fragment + block->length) != (gsize)b->heap_fragment) { - g_warning("[BUG] wrong block chain detected. (block: %p heap: %p length: %" G_GSIZE_FORMAT ") is chained to (block: %p heap: %p length: %" G_GSIZE_FORMAT ")", block, block->heap_fragment, block->length, b, b->heap_fragment, b->length); + hg_log_warning("[BUG] wrong block chain detected. (block: %p heap: %p length: %" G_GSIZE_FORMAT ") is chained to (block: %p heap: %p length: %" G_GSIZE_FORMAT ")", block, block->heap_fragment, block->length, b, b->heap_fragment, b->length); break; } /* it could be merged now */ @@ -591,17 +592,17 @@ _hg_allocator_bfit_real_free(HgMemPool *pool, hg_mem_get_object__inline(data, obj); if (obj == NULL) { - g_warning("[BUG] Unknown object %p is going to be destroyed.", data); + hg_log_warning("[BUG] Unknown object %p is going to be destroyed.", data); return; } block = obj->subid; if (block == NULL) { - g_warning("[BUG] Broken object %p is going to be destroyed.", data); + hg_log_warning("[BUG] Broken object %p is going to be destroyed.", data); return; } if (hg_btree_find(priv->obj2block_tree, block->heap_fragment) == NULL) { - g_warning("[BUG] Failed to remove an object %p (block: %p) from list.", - data, block); + hg_log_warning("[BUG] Failed to remove an object %p (block: %p) from list.", + data, block); return; } hg_btree_remove(priv->obj2block_tree, block->heap_fragment); @@ -681,7 +682,7 @@ _hg_allocator_bfit_real_resize(HgMemObject *object, HgAllocatorBFitPrivate *priv = pool->allocator->private; if (block == NULL) { - g_warning("Failed to allocate a block for resizing."); + hg_log_warning("Failed to allocate a block for resizing."); return NULL; } block->prev = blk; @@ -815,7 +816,7 @@ _hg_allocator_bfit_real_gc_mark(HgMemPool *pool) for (list = pool->root_node; list != NULL; list = g_list_next(list)) { hg_mem_get_object__inline(list->data, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p is in the root node.", list->data); + hg_log_warning("[BUG] Invalid object %p is in the root node.", list->data); } else { if (!hg_mem_is_gc_mark__inline(obj)) { hg_mem_gc_mark__inline(obj); @@ -921,7 +922,7 @@ _hg_allocator_bfit_real_save_snapshot(HgMemPool *pool) retval = hg_mem_alloc_with_flags(pool, sizeof (HgMemSnapshot), HG_FL_HGOBJECT | HG_FL_COMPLEX); if (retval == NULL) { - g_warning("Failed to allocate a memory for snapshot."); + hg_log_warning("Failed to allocate a memory for snapshot."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -1010,7 +1011,7 @@ _hg_allocator_bfit_snapshot_real_set_flags(gpointer data, obj = chunk->heap_chunks; if (!HG_CHECK_MAGIC_CODE (obj, HG_MEM_HEADER)) { - g_warning("[BUG] Invalid object %p to be marked in snapshot.", obj); + hg_log_warning("[BUG] Invalid object %p to be marked in snapshot.", obj); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); diff --git a/hieroglyph/hgarray.c b/hieroglyph/hgarray.c index 459f128..0e3cda0 100644 --- a/hieroglyph/hgarray.c +++ b/hieroglyph/hgarray.c @@ -29,6 +29,7 @@ #include "hgarray.h" #include "hgstring.h" #include "hgbtree.h" +#include "hglog.h" #include "hgmem.h" #include "hgvaluenode.h" #include "hgfile.h" @@ -83,7 +84,7 @@ _hg_array_real_set_flags(gpointer data, if (array->name) { hg_mem_get_object__inline(array->name, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: Array name", array->name); + hg_log_warning("[BUG] Invalid object %p to be marked: Array name", array->name); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -92,7 +93,7 @@ _hg_array_real_set_flags(gpointer data, for (i = 0; i < array->n_arrays; i++) { hg_mem_get_object__inline(array->current[i], obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: Array %d", array->current[i], i); + hg_log_warning("[BUG] Invalid object %p to be marked: Array %d", array->current[i], i); } else { #ifdef DEBUG_GC G_STMT_START { @@ -112,7 +113,7 @@ _hg_array_real_set_flags(gpointer data, if (array->arrays) { hg_mem_get_object__inline(array->arrays, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: Array", array->arrays); + hg_log_warning("[BUG] Invalid object %p to be marked: Array", array->arrays); } else { #ifdef DEBUG_GC G_STMT_START { @@ -164,7 +165,7 @@ _hg_array_real_dup(gpointer data) retval = hg_array_new(obj->pool, array->n_arrays); if (retval == NULL) { - g_warning("Failed to duplicate an array."); + hg_log_warning("Failed to duplicate an array."); return NULL; } memcpy(retval->arrays, array->current, sizeof (HgValueNode *) * array->n_arrays); @@ -188,13 +189,13 @@ _hg_array_real_copy(gpointer data) if (hg_mem_is_copying(obj)) { /* circular reference happened. */ - g_warning("Circular reference happened in %p (mem: %p). copying entire object is impossible.", data, obj); + hg_log_warning("Circular reference happened in %p (mem: %p). copying entire object is impossible.", data, obj); return array; } hg_mem_set_copying(obj); retval = hg_array_new(obj->pool, array->n_arrays); if (retval == NULL) { - g_warning("Failed to copy an array."); + hg_log_warning("Failed to copy an array."); hg_mem_unset_copying(obj); return NULL; } @@ -345,7 +346,7 @@ hg_array_append_forcibly(HgArray *array, if (!force) { if (!hg_mem_pool_is_own_object(obj->pool, node)) { - g_warning("node %p isn't allocated from a pool %s\n", node, hg_mem_pool_get_name(obj->pool)); + hg_log_warning("node %p isn't allocated from a pool %s\n", node, hg_mem_pool_get_name(obj->pool)); return FALSE; } @@ -367,7 +368,7 @@ hg_array_append_forcibly(HgArray *array, sizeof (HgValueNode *) * (array->allocated_arrays + HG_ARRAY_ALLOC_SIZE)); if (p == NULL) { - g_warning("Failed to resize an array."); + hg_log_warning("Failed to resize an array."); return FALSE; } else { array->current = array->arrays = p; @@ -412,7 +413,7 @@ hg_array_replace_forcibly(HgArray *array, if (!force) { if (!hg_mem_pool_is_own_object(obj->pool, node)) { - g_warning("node %p isn't allocated from a pool %s\n", node, hg_mem_pool_get_name(obj->pool)); + hg_log_warning("node %p isn't allocated from a pool %s\n", node, hg_mem_pool_get_name(obj->pool)); return FALSE; } @@ -489,7 +490,7 @@ hg_array_fix_array_size(HgArray *array) } p = hg_mem_resize(array->arrays, sizeof (gpointer) * array->n_arrays); if (p == NULL) { - g_warning("Failed to resize an array."); + hg_log_warning("Failed to resize an array."); return FALSE; } array->current = array->arrays = p; diff --git a/hieroglyph/hgbtree.c b/hieroglyph/hgbtree.c index cbe73a2..3e07ed1 100644 --- a/hieroglyph/hgbtree.c +++ b/hieroglyph/hgbtree.c @@ -26,6 +26,7 @@ #endif #include "hgbtree.h" +#include "hglog.h" #include "hgmem.h" @@ -131,8 +132,8 @@ _hg_btree_page_real_set_flags(gpointer data, if (page->key) { hg_mem_get_object__inline(page->key, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTreePage key", - page->key); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTreePage key", + page->key); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } @@ -140,21 +141,21 @@ _hg_btree_page_real_set_flags(gpointer data, if (page->val) { hg_mem_get_object__inline(page->val, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTreePage val", - page->val); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTreePage val", + page->val); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } } if (page->page == NULL && page->n_data > 0) { - g_warning("[BUG] HgBTree structure corruption. no real data, but it says there are %d item(s).", - page->n_data); + hg_log_warning("[BUG] HgBTree structure corruption. no real data, but it says there are %d item(s).", + page->n_data); } if (page->page) { hg_mem_get_object__inline(page->page, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTreePage page", - page->page); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTreePage page", + page->page); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } @@ -167,16 +168,16 @@ _hg_btree_page_real_set_flags(gpointer data, if (page->page[i]) { hg_mem_get_object__inline(page->page[i], obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTreePage page[%d]", - page->page[i], i); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTreePage page[%d]", + page->page[i], i); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } } hg_mem_get_object__inline(page->val[i], obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTreePage val[%d]", - page->val[i], i); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTreePage val[%d]", + page->val[i], i); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } @@ -184,8 +185,8 @@ _hg_btree_page_real_set_flags(gpointer data, if (page->page[page->n_data]) { hg_mem_get_object__inline(page->page[page->n_data], obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTreePage page[%d]", - page->page[page->n_data], page->n_data); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTreePage page[%d]", + page->page[page->n_data], page->n_data); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } @@ -273,7 +274,7 @@ _hg_btree_real_set_flags(gpointer data, if (tree->root) { hg_mem_get_object__inline(tree->root, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgBTree", tree->root); + hg_log_warning("[BUG] Invalid object %p to be marked: HgBTree", tree->root); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -413,7 +414,7 @@ hg_btree_page_blance(HgBTreePage *page, size = page_size + 1; new = hg_btree_page_new(page->parent); if (new == NULL) { - g_warning("Failed to allocate a memory."); + hg_log_warning("Failed to allocate a memory."); return; } for (i = size + 1; i <= page_size * 2; i++) { @@ -715,7 +716,7 @@ hg_btree_add(HgBTree *tree, if (!inserted) { page = hg_btree_page_new(tree); if (page == NULL) { - g_warning("Failed to allocate a tree page."); + hg_log_warning("Failed to allocate a tree page."); return; } page->n_data = 1; diff --git a/hieroglyph/hgdevice.c b/hieroglyph/hgdevice.c index 5551111..2d5f233 100644 --- a/hieroglyph/hgdevice.c +++ b/hieroglyph/hgdevice.c @@ -28,6 +28,7 @@ #include <string.h> #include <gmodule.h> #include "hgdevice.h" +#include "hglog.h" /* * Private Functions @@ -45,14 +46,14 @@ _hg_device_open(const gchar *filename) if (open_symbol && close_symbol) { retval = ((HgDeviceOpenFunc)open_symbol) (); } else { - g_warning(g_module_error()); + hg_log_warning(g_module_error()); g_module_close(module); return NULL; } #ifdef DEBUG_MODULES } else { - g_warning(g_module_error()); + hg_log_warning(g_module_error()); #endif /* DEBUG_MODULES */ } @@ -107,7 +108,7 @@ hg_device_new(const gchar *name) g_free(fullmodname); } if (retval == NULL) - g_warning("No `%s' device module found.", realname); + hg_log_warning("No `%s' device module found.", realname); g_free(realname); g_free(modulename); @@ -164,7 +165,7 @@ hg_device_draw(HgDevice *device, render->u.debug.func(render->u.debug.data); break; default: - g_warning("Unknown rendering code %d\n", render->u.type); + hg_log_warning("Unknown rendering code %d\n", render->u.type); break; } } diff --git a/hieroglyph/hgdict.c b/hieroglyph/hgdict.c index e92b7fa..cefe1ea 100644 --- a/hieroglyph/hgdict.c +++ b/hieroglyph/hgdict.c @@ -27,6 +27,7 @@ #include "hgdict.h" #include "hgbtree.h" +#include "hglog.h" #include "hgmem.h" #include "hglist.h" #include "hgstring.h" @@ -910,7 +911,7 @@ _hg_dict_traverse_set_flags(gpointer key, HgListIter iter = hg_list_iter_new(list); if (iter == NULL) { - g_warning("Failed to create an iter to set flags from Dict."); + hg_log_warning("Failed to create an iter to set flags from Dict."); return FALSE; } /* no need to mark a key because it's hash value here */ @@ -921,7 +922,7 @@ _hg_dict_traverse_set_flags(gpointer key, hg_mem_get_object__inline(node, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: DictNode [list %p]", node, list); + hg_log_warning("[BUG] Invalid object %p to be marked: DictNode [list %p]", node, list); } else { #ifdef DEBUG_GC G_STMT_START { @@ -954,7 +955,7 @@ _hg_dict_real_set_flags(gpointer data, hg_mem_get_object__inline(dict->dict, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: Dict tree", dict->dict); + hg_log_warning("[BUG] Invalid object %p to be marked: Dict tree", dict->dict); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -988,12 +989,12 @@ _hg_dict_traverse_dup(gpointer key, hg_mem_get_object__inline(key, obj); nnkey = hg_object_dup((HgObject *)nkey); if (nnkey == NULL) { - g_warning("[BUG] Failed to duplicate a key during traversing dict."); + hg_log_warning("[BUG] Failed to duplicate a key during traversing dict."); nnkey = nkey; } nnval = hg_object_dup((HgObject *)nval); if (nnval == NULL) { - g_warning("[BUG] Failed to duplicate a val during traversing dict."); + hg_log_warning("[BUG] Failed to duplicate a val during traversing dict."); nnval = nval; } hg_dict_insert(obj->pool, dict, nnkey, nnval); @@ -1013,7 +1014,7 @@ _hg_dict_real_dup(gpointer data) retval = hg_dict_new(obj->pool, dict->n_prealloc); if (retval == NULL) { - g_warning("Failed to duplicate a dict."); + hg_log_warning("Failed to duplicate a dict."); return NULL; } hg_dict_traverse(dict, _hg_dict_traverse_dup, retval); @@ -1046,7 +1047,7 @@ _hg_dict_node_real_set_flags(gpointer data, hg_mem_get_object__inline(node->key, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: Dict key", node->key); + hg_log_warning("[BUG] Invalid object %p to be marked: Dict key", node->key); } else { #ifdef DEBUG_GC G_STMT_START { @@ -1064,7 +1065,7 @@ _hg_dict_node_real_set_flags(gpointer data, } hg_mem_get_object__inline(node->val, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: Dict val", node->val); + hg_log_warning("[BUG] Invalid object %p to be marked: Dict val", node->val); } else { #ifdef DEBUG_GC G_STMT_START { @@ -1105,7 +1106,7 @@ hg_dict_node_new(HgMemPool *pool) sizeof (HgDictNode), HG_FL_HGOBJECT | HG_FL_RESTORABLE); if (retval == NULL) { - g_warning("Failed to create a dict node."); + hg_log_warning("Failed to create a dict node."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -1205,7 +1206,7 @@ hg_dict_new(HgMemPool *pool, sizeof (HgDict), HG_FL_HGOBJECT | HG_FL_RESTORABLE | HG_FL_COMPLEX); if (retval == NULL) { - g_warning("Failed to create a dict."); + hg_log_warning("Failed to create a dict."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -1261,12 +1262,12 @@ hg_dict_insert_forcibly(HgMemPool *pool, if (!force) { if (!hg_mem_pool_is_own_object(obj->pool, key)) { - g_warning("key %p isn't allocated from a pool %s\n", key, hg_mem_pool_get_name(obj->pool)); + hg_log_warning("key %p isn't allocated from a pool %s\n", key, hg_mem_pool_get_name(obj->pool)); return FALSE; } if (!hg_mem_pool_is_own_object(obj->pool, val)) { - g_warning("value %p isn't allocated from a pool %s\n", val, hg_mem_pool_get_name(obj->pool)); + hg_log_warning("value %p isn't allocated from a pool %s\n", val, hg_mem_pool_get_name(obj->pool)); return FALSE; } @@ -1303,7 +1304,7 @@ hg_dict_insert_forcibly(HgMemPool *pool, dict->n_keys++; } if (dict->n_keys > dict->n_prealloc) { - g_warning("FIXME: need to recalculate the prime."); + hg_log_warning("FIXME: need to recalculate the prime."); } return TRUE; @@ -1463,7 +1464,7 @@ hg_dict_first(HgDict *dict, } liter = hg_list_iter_new(iter->val); if (liter == NULL) { - g_warning("Failed to create an iter to traverse a Dict."); + hg_log_warning("Failed to create an iter to traverse a Dict."); hg_btree_iter_free(iter); return FALSE; } diff --git a/hieroglyph/hgfile.c b/hieroglyph/hgfile.c index 458578a..8d890d1 100644 --- a/hieroglyph/hgfile.c +++ b/hieroglyph/hgfile.c @@ -32,6 +32,7 @@ #include <sys/stat.h> #include "hgfile.h" #include "hgallocator-bfit.h" +#include "hglog.h" #include "hgmem.h" #include "hgstring.h" #include "hglineedit.h" @@ -114,7 +115,7 @@ _hg_file_object_real_set_flags(gpointer data, if (file->filename) { hg_mem_get_object__inline(file->filename, obj); if (obj == NULL) { - g_warning("Invalid object %p to be marked: HgFileObject->filename", file->filename); + hg_log_warning("Invalid object %p to be marked: HgFileObject->filename", file->filename); } else { #ifdef DEBUG_GC G_STMT_START { @@ -133,7 +134,7 @@ _hg_file_object_real_set_flags(gpointer data, file->is.buf.buffer) { hg_mem_get_object__inline(file->is.buf.buffer, obj); if (obj == NULL) { - g_warning("Invalid object %p to be marked: HgFileObject->buffer", file->is.buf.buffer); + hg_log_warning("Invalid object %p to be marked: HgFileObject->buffer", file->is.buf.buffer); } else { #ifdef DEBUG_GC G_STMT_START { @@ -284,7 +285,7 @@ hg_file_object_new(HgMemPool *pool, retval = hg_mem_alloc_with_flags(pool, sizeof (HgFileObject), HG_FL_HGOBJECT | HG_FL_COMPLEX); if (retval == NULL) { - g_warning("Failed to create a file object."); + hg_log_warning("Failed to create a file object."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -306,7 +307,7 @@ hg_file_object_new(HgMemPool *pool, len = strlen(p); retval->filename = hg_mem_alloc(pool, len + 1); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, p, len); @@ -340,7 +341,7 @@ hg_file_object_new(HgMemPool *pool, len = strlen(p); retval->filename = hg_mem_alloc(pool, len + 1); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, p, len); @@ -352,7 +353,7 @@ hg_file_object_new(HgMemPool *pool, retval->is.buf.buffer = NULL; retval->is.buf.buffer = hg_mem_alloc(pool, retval->is.buf.bufsize); if (retval->is.buf.buffer == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } memcpy(retval->is.buf.buffer, p, retval->is.buf.bufsize); @@ -361,7 +362,7 @@ hg_file_object_new(HgMemPool *pool, case HG_FILE_TYPE_STDIN: retval->filename = hg_mem_alloc(pool, 6); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, "stdin", 5); @@ -375,7 +376,7 @@ hg_file_object_new(HgMemPool *pool, case HG_FILE_TYPE_STDOUT: retval->filename = hg_mem_alloc(pool, 7); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, "stdout", 6); @@ -387,7 +388,7 @@ hg_file_object_new(HgMemPool *pool, case HG_FILE_TYPE_STDERR: retval->filename = hg_mem_alloc(pool, 7); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, "stderr", 6); @@ -399,19 +400,19 @@ hg_file_object_new(HgMemPool *pool, case HG_FILE_TYPE_STATEMENT_EDIT: lineedit = (HgLineEdit *)va_arg(ap, HgLineEdit *); if (lineedit == NULL) { - g_warning("[BUG] No HgLineEdit instance."); + hg_log_warning("[BUG] No HgLineEdit instance."); return NULL; } retval->filename = hg_mem_alloc(pool, 15); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, "%statementedit", 14); retval->filename[14] = 0; p = hg_line_edit_get_statement(lineedit, NULL); if (p == NULL) { - g_warning("Failed to read a statement."); + hg_log_warning("Failed to read a statement."); return NULL; } retval->access_mode = HG_FILE_MODE_READ; @@ -419,7 +420,7 @@ hg_file_object_new(HgMemPool *pool, retval->is.buf.buffer = NULL; retval->is.buf.buffer = hg_mem_alloc(pool, retval->is.buf.bufsize); if (retval->is.buf.buffer == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } memcpy(retval->is.buf.buffer, p, retval->is.buf.bufsize); @@ -429,19 +430,19 @@ hg_file_object_new(HgMemPool *pool, case HG_FILE_TYPE_LINE_EDIT: lineedit = (HgLineEdit *)va_arg(ap, HgLineEdit *); if (lineedit == NULL) { - g_warning("[BUG] No HgLineEdit instance."); + hg_log_warning("[BUG] No HgLineEdit instance."); return NULL; } retval->filename = hg_mem_alloc(pool, 10); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, "%lineedit", 9); retval->filename[9] = 0; p = hg_line_edit_get_line(lineedit, NULL, TRUE); if (p == NULL) { - g_warning("Failed to read a statement."); + hg_log_warning("Failed to read a statement."); return NULL; } retval->access_mode = HG_FILE_MODE_READ; @@ -449,7 +450,7 @@ hg_file_object_new(HgMemPool *pool, retval->is.buf.buffer = NULL; retval->is.buf.buffer = hg_mem_alloc(pool, retval->is.buf.bufsize); if (retval->is.buf.buffer == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } memcpy(retval->is.buf.buffer, p, retval->is.buf.bufsize); @@ -462,7 +463,7 @@ hg_file_object_new(HgMemPool *pool, len = strlen(p); retval->filename = hg_mem_alloc(pool, len + 1); if (retval->filename == NULL) { - g_warning("Failed to allocate a memory for file object."); + hg_log_warning("Failed to allocate a memory for file object."); return NULL; } strncpy(retval->filename, p, len); @@ -471,7 +472,7 @@ hg_file_object_new(HgMemPool *pool, retval->is.callback.user_data = (gpointer)va_arg(ap, gpointer); break; default: - g_warning("Unknown file type %d\n", HG_FILE_GET_FILE_TYPE (retval)); + hg_log_warning("Unknown file type %d\n", HG_FILE_GET_FILE_TYPE (retval)); retval = NULL; break; } @@ -510,7 +511,7 @@ hg_file_object_has_error(HgFileObject *object) object->error = object->is.callback.vtable->get_error_code(object->is.callback.user_data); break; default: - g_warning("[BUG] Invalid file type %d was given to check the error.", HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("[BUG] Invalid file type %d was given to check the error.", HG_FILE_GET_FILE_TYPE (object)); return TRUE; } @@ -556,7 +557,7 @@ hg_file_object_read(HgFileObject *object, /* FIXME: need to handle ungetc here properly */ if (object->ungetc != 0) { - g_warning("FIXME: ungetc handling not yet implemented!!"); + hg_log_warning("FIXME: ungetc handling not yet implemented!!"); } switch (HG_FILE_GET_FILE_TYPE (object)) { case HG_FILE_TYPE_FILE: @@ -600,7 +601,7 @@ hg_file_object_read(HgFileObject *object, object->error = object->is.callback.vtable->get_error_code(object->is.callback.user_data); break; default: - g_warning("[BUG] Invalid file type %d was given to be read.", HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("[BUG] Invalid file type %d was given to be read.", HG_FILE_GET_FILE_TYPE (object)); object->error = EACCES; break; } @@ -649,7 +650,7 @@ hg_file_object_write(HgFileObject *object, object->error = object->is.callback.vtable->get_error_code(object->is.callback.user_data); break; default: - g_warning("[BUG] Invalid file type %d to be wrriten.", HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("[BUG] Invalid file type %d to be wrriten.", HG_FILE_GET_FILE_TYPE (object)); object->error = EACCES; break; } @@ -699,7 +700,7 @@ hg_file_object_getc(HgFileObject *object) object->error = object->is.callback.vtable->get_error_code(object->is.callback.user_data); break; default: - g_warning("[BUG] Invalid file type %d was given to be get a character.", HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("[BUG] Invalid file type %d was given to be get a character.", HG_FILE_GET_FILE_TYPE (object)); break; } } @@ -760,7 +761,7 @@ hg_file_object_flush(HgFileObject *object) retval = object->is.callback.vtable->flush(object->is.callback.user_data); break; default: - g_warning("Invalid file type %d was given to be flushed.", HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("Invalid file type %d was given to be flushed.", HG_FILE_GET_FILE_TYPE (object)); break; } @@ -805,7 +806,7 @@ hg_file_object_seek(HgFileObject *object, object->is.file.mmap.pos = object->is.file.mmap.bufsize; break; default: - g_warning("Invalid whence `%d' was given.", whence); + hg_log_warning("Invalid whence `%d' was given.", whence); object->error = EINVAL; break; } @@ -844,7 +845,7 @@ hg_file_object_seek(HgFileObject *object, object->is.buf.pos = object->is.buf.bufsize; break; default: - g_warning("Invalid whence `%d' was given.", whence); + hg_log_warning("Invalid whence `%d' was given.", whence); object->error = EINVAL; break; } @@ -853,7 +854,7 @@ hg_file_object_seek(HgFileObject *object, case HG_FILE_TYPE_STDIN: case HG_FILE_TYPE_STDOUT: case HG_FILE_TYPE_STDERR: - g_warning("Not supported to be sought."); + hg_log_warning("Not supported to be sought."); object->error = ESPIPE; break; case HG_FILE_TYPE_BUFFER_WITH_CALLBACK: @@ -861,8 +862,8 @@ hg_file_object_seek(HgFileObject *object, object->error = object->is.callback.vtable->get_error_code(object->is.callback.user_data); break; default: - g_warning("Unknown file type %d was given to be sought.", - HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("Unknown file type %d was given to be sought.", + HG_FILE_GET_FILE_TYPE (object)); break; } object->ungetc = 0; @@ -903,8 +904,8 @@ hg_file_object_close(HgFileObject *object) object->is.callback.vtable->close(object->is.callback.user_data); break; default: - g_warning("Unknown file type %d was given to be closed.", - HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("Unknown file type %d was given to be closed.", + HG_FILE_GET_FILE_TYPE (object)); break; } } @@ -934,8 +935,8 @@ hg_file_object_is_closed(HgFileObject *object) retval = object->is.callback.vtable->is_closed(object->is.callback.user_data); break; default: - g_warning("Unknown file type %d was given to be closed.", - HG_FILE_GET_FILE_TYPE (object)); + hg_log_warning("Unknown file type %d was given to be closed.", + HG_FILE_GET_FILE_TYPE (object)); break; } diff --git a/hieroglyph/hggraphics.c b/hieroglyph/hggraphics.c index 028e79b..eb131f1 100644 --- a/hieroglyph/hggraphics.c +++ b/hieroglyph/hggraphics.c @@ -27,6 +27,7 @@ #include <string.h> #include "hggraphics.h" +#include "hglog.h" #include "hgmem.h" #include "hgarray.h" #include "hgdict.h" @@ -80,7 +81,7 @@ _hg_graphic_state_real_set_flags(gpointer data, if (gstate->member) { \ hg_mem_get_object__inline(gstate->member, obj); \ if (obj == NULL) { \ - g_warning("Invalid object %p to be marked: Graphics", gstate->member); \ + hg_log_warning("Invalid object %p to be marked: Graphics", gstate->member); \ } else { \ hg_mem_add_flags__inline(obj, flags, TRUE); \ } \ @@ -127,7 +128,7 @@ _hg_graphic_state_real_copy(gpointer data) return NULL; retval = hg_graphic_state_new(obj->pool); if (retval == NULL) { - g_warning("Failed to duplicate a graphic state."); + hg_log_warning("Failed to duplicate a graphic state."); return NULL; } memcpy(retval, data, sizeof (HgGraphicState)); @@ -177,7 +178,7 @@ _hg_graphics_real_set_flags(gpointer data, if (member) { \ hg_mem_get_object__inline(member, obj); \ if (obj == NULL) { \ - g_warning("Invalid object %p to be marked: Graphics", member); \ + hg_log_warning("Invalid object %p to be marked: Graphics", member); \ } else { \ hg_mem_add_flags__inline(obj, flags, TRUE); \ } \ @@ -253,7 +254,7 @@ hg_graphic_state_new(HgMemPool *pool) return retval; } - g_warning("Failed to create a graphic state."); + hg_log_warning("Failed to create a graphic state."); return NULL; } @@ -285,7 +286,7 @@ hg_graphics_new(HgMemPool *pool) return retval; } - g_warning("Failed to create a graphic state."); + hg_log_warning("Failed to create a graphic state."); return NULL; } @@ -359,7 +360,7 @@ hg_graphics_set_graphic_size(HgGraphics *graphics, g_return_val_if_fail (graphics->current_gstate != NULL, FALSE); if (graphics->current_page->node) { - g_warning("Can't change the page size after the rendering code is invoked."); + hg_log_warning("Can't change the page size after the rendering code is invoked."); return FALSE; } diff --git a/hieroglyph/hglineedit.c b/hieroglyph/hglineedit.c index 28861c8..8ba8339 100644 --- a/hieroglyph/hglineedit.c +++ b/hieroglyph/hglineedit.c @@ -30,6 +30,7 @@ #include <errno.h> #include "hglineedit.h" #include "hgfile.h" +#include "hglog.h" #include "hgmem.h" @@ -81,13 +82,13 @@ _hg_line_edit_real_set_flags(gpointer data, hg_mem_get_object__inline(lineedit->stdin, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgLineEdit", lineedit->stdin); + hg_log_warning("[BUG] Invalid object %p to be marked: HgLineEdit", lineedit->stdin); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } hg_mem_get_object__inline(lineedit->stdout, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgLineEdit", lineedit->stdout); + hg_log_warning("[BUG] Invalid object %p to be marked: HgLineEdit", lineedit->stdout); } else { hg_mem_add_flags__inline(obj, flags, TRUE); } diff --git a/hieroglyph/hglist.c b/hieroglyph/hglist.c index c4a48d4..01e24ff 100644 --- a/hieroglyph/hglist.c +++ b/hieroglyph/hglist.c @@ -26,6 +26,7 @@ #endif #include "hglist.h" +#include "hglog.h" #include "hgmem.h" #include "hgallocator-bfit.h" @@ -122,8 +123,8 @@ _hg_list_real_set_flags(gpointer data, if (list->data && HG_LIST_IS_OBJECT_NODE (list)) { hg_mem_get_object__inline(list->data, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgList data", - list->data); + hg_log_warning("[BUG] Invalid object %p to be marked: HgList data", + list->data); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -132,7 +133,7 @@ _hg_list_real_set_flags(gpointer data, if ((tmp = hg_list_next(list)) != NULL) { hg_mem_get_object__inline(tmp, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgList next node", tmp); + hg_log_warning("[BUG] Invalid object %p to be marked: HgList next node", tmp); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -141,7 +142,7 @@ _hg_list_real_set_flags(gpointer data, if ((tmp = hg_list_previous(list)) != NULL) { hg_mem_get_object__inline(tmp, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgList previous node", tmp); + hg_log_warning("[BUG] Invalid object %p to be marked: HgList previous node", tmp); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -184,21 +185,21 @@ _hg_list_iter_real_set_flags(gpointer data, hg_mem_get_object__inline(iter->top, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgListIter top node", iter->top); + hg_log_warning("[BUG] Invalid object %p to be marked: HgListIter top node", iter->top); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); } hg_mem_get_object__inline(iter->last, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgListIter last node", iter->last); + hg_log_warning("[BUG] Invalid object %p to be marked: HgListIter last node", iter->last); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); } hg_mem_get_object__inline(iter->current, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgListIter current node", iter->current); + hg_log_warning("[BUG] Invalid object %p to be marked: HgListIter current node", iter->current); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -239,7 +240,7 @@ _hg_list_get_last_node(HgList *list) if (hg_list_next(tmp) != NULL || hg_list_previous(tmp) != NULL) { /* found incomplete node */ - g_warning("[BUG] incomplete HgList node %p found.", tmp); + hg_log_warning("[BUG] incomplete HgList node %p found.", tmp); } else { /* this can be used as the last node */ return tmp; @@ -253,8 +254,8 @@ _hg_list_get_last_node(HgList *list) /* validate node */ if (tmp == list) { /* detected the circular reference */ - g_warning("[BUG] Circular reference happened without the last node mark: %p", - list); + hg_log_warning("[BUG] Circular reference happened without the last node mark: %p", + list); /* workaround */ return hg_list_previous(list); } @@ -292,8 +293,8 @@ _hg_list_real_append(HgList *list, if (!HG_LIST_IS_UNUSED (last)) { hg_mem_get_object__inline(last, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p is given to append a list.", - last); + hg_log_warning("[BUG] Invalid object %p is given to append a list.", + last); return NULL; } tmp = hg_list_new(obj->pool); @@ -332,8 +333,8 @@ _hg_list_real_prepend(HgList *list, if (!HG_LIST_IS_UNUSED (top)) { hg_mem_get_object__inline(top, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p is given to prepend a list.", - top); + hg_log_warning("[BUG] Invalid object %p is given to prepend a list.", + top); return NULL; } tmp = hg_list_new(obj->pool); @@ -458,7 +459,7 @@ hg_list_length(HgList *list) /* validate node */ if (l == NULL) { - g_warning("[BUG] no loop detected in HgList %p", list); + hg_log_warning("[BUG] no loop detected in HgList %p", list); } return retval; @@ -504,8 +505,8 @@ hg_list_remove(HgList *list, /* validate node */ if (l == NULL) { - g_warning("[BUG] no loop detected in HgList %p during removing %p", - list, data); + hg_log_warning("[BUG] no loop detected in HgList %p during removing %p", + list, data); top = list; } else { if (!top) diff --git a/hieroglyph/hglog.c b/hieroglyph/hglog.c new file mode 100644 index 0000000..329aeba --- /dev/null +++ b/hieroglyph/hglog.c @@ -0,0 +1,206 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hglog.c + * Copyright (C) 2006 Akira TAGOH + * + * Authors: + * Akira TAGOH <at@gclab.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "hglog.h" +#include "hgdict.h" +#include "hgfile.h" +#include "hgmem.h" +#include "hgstring.h" +#include "hgvaluenode.h" +#include "vm.h" + + +static void _hg_log_default_handler(HgLogType log_type, + const gchar *subtype, + const gchar *message); + +static gboolean __hg_log_initialized = FALSE; +static HgDict *__hg_log_options_dict = NULL; +static HgVM *__hg_log_vm = NULL; +static gchar const *log_type_to_string[] = { + "Info", + "Debug", + "Warning", + "Error", +}; +static HgLogFunc __hg_log_handler = _hg_log_default_handler; + +/* + * Private Functions + */ +static void +_hg_log_default_handler(HgLogType log_type, + const gchar *subtype, + const gchar *message) +{ + HgFileObject *file; + + if (__hg_log_vm) { + file = hg_vm_get_io(__hg_log_vm, VM_IO_STDERR); + } else { + if (!hg_file_is_initialized()) + hg_file_init(); + file = __hg_file_stderr; + } + hg_file_object_printf(file, "%s ***%s%s%s %s\n", + log_type_to_string[log_type], + (subtype ? " " : ""), + (subtype ? subtype : ""), + (subtype ? ":" : ""), + message); +} + +/* + * Public Functions + */ +/* initializer */ +gboolean +hg_log_init(HgVM *vm, + HgDict *dict) +{ + HgMemObject *obj; + + g_return_val_if_fail (vm != NULL, FALSE); + g_return_val_if_fail (dict != NULL, FALSE); + + if (__hg_log_options_dict == NULL) { + hg_mem_get_object__inline(dict, obj); + if (obj == NULL) { + hg_log_warning("Invalid object %p to be set as Log Dict.", dict); + return FALSE; + } + hg_mem_set_lock(obj); + __hg_log_options_dict = dict; + + hg_mem_get_object__inline(vm, obj); + if (obj == NULL) { + hg_log_warning("Invalid object %p to be set as Log VM.", vm); + return FALSE; + } + hg_mem_set_lock(obj); + __hg_log_vm = vm; + __hg_log_handler = _hg_log_default_handler; + + __hg_log_initialized = TRUE; + } + + return TRUE; +} + +void +hg_log_finalize(void) +{ + HgMemObject *obj; + + if (__hg_log_initialized) { + hg_mem_get_object__inline(__hg_log_options_dict, obj); + if (obj != NULL) { + hg_mem_set_unlock(obj); + } + __hg_log_options_dict = NULL; + hg_mem_get_object__inline(__hg_log_vm, obj); + if (obj != NULL) { + hg_mem_set_unlock(obj); + } + __hg_log_vm = NULL; + __hg_log_initialized = FALSE; + } +} + +/* utilities */ +void +hg_log_set_default_handler(HgLogFunc func) +{ + g_return_if_fail (func); + + __hg_log_handler = func; +} + +void +hg_log(HgLogType log_type, + const gchar *subtype, + const gchar *format, + ...) +{ + va_list ap; + + va_start(ap, format); + hg_logv(log_type, subtype, format, ap); + va_end(ap); +} + +void +hg_logv(HgLogType log_type, + const gchar *subtype, + const gchar *format, + va_list va_args) +{ + HgValueNode *node; + HgString *string = NULL; + + g_return_if_fail (format != NULL); + + if (subtype == NULL) { + gchar *buffer = g_strdup_vprintf(format, va_args); + + /* just invoke a default handler */ + __hg_log_handler(log_type, subtype, buffer); + g_free(buffer); + return; + } + + g_return_if_fail (__hg_log_initialized); + + if ((node = hg_dict_lookup_with_string(__hg_log_options_dict, subtype)) != NULL) { + HgMemPool *pool = hg_vm_get_current_pool(__hg_log_vm); + + string = hg_string_new(pool, -1); + hg_string_append_vprintf(string, format, va_args); + + if (HG_IS_VALUE_BOOLEAN (node)) { + if (HG_VALUE_GET_BOOLEAN (node)) { + /* just invoke a default handler */ + __hg_log_handler(log_type, subtype, hg_string_get_string(string)); + } + } else if (HG_IS_VALUE_OPERATOR (node) || + (HG_IS_VALUE_ARRAY (node) && hg_object_is_executable((HgObject *)node))) { + HgValueNode *strnode = NULL, *subnode, *lognode; + HG_VALUE_MAKE_STRING (strnode, string); + lognode = hg_vm_get_name_node(__hg_log_vm, log_type_to_string[log_type]); + subnode = hg_vm_get_name_node(__hg_log_vm, subtype); + hg_log_warning("FIXME: not yet supported."); + + if (strnode) + hg_mem_free(strnode); + } else { + hg_log_warning("Invalid object specified for logger."); + } + + if (string) + hg_mem_free(string); + } +} diff --git a/hieroglyph/hglog.h b/hieroglyph/hglog.h new file mode 100644 index 0000000..c2aa462 --- /dev/null +++ b/hieroglyph/hglog.h @@ -0,0 +1,66 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hglog.h + * Copyright (C) 2006 Akira TAGOH + * + * Authors: + * Akira TAGOH <at@gclab.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifndef __HG_LOG_H__ +#define __HG_LOG_H__ + +#include <hieroglyph/hgtypes.h> + +G_BEGIN_DECLS + + +typedef void (*HgLogFunc)(HgLogType log_type, + const gchar *subtype, + const gchar *message); + +#define hg_log_info(...) \ + hg_log(HG_LOG_TYPE_INFO, NULL, __VA_ARGS__) +#ifdef DEBUG +#define hg_log_debug(_type_, ...) \ + hg_log(HG_LOG_TYPE_DEBUG, (_type_), __VA_ARGS__) +#else +#define hg_log_debug(_type_, ...) +#endif /* DEBUG */ +#define hg_log_warning(...) \ + hg_log(HG_LOG_TYPE_WARNING, NULL, __VA_ARGS__) +#define hg_log_error(...) \ + hg_log(HG_LOG_TYPE_ERROR, NULL, __VA_ARGS__) + + +gboolean hg_log_init (HgVM *vm, + HgDict *dict); +void hg_log_finalize (void); +void hg_log_set_default_handler(HgLogFunc func); +void hg_log (HgLogType log_type, + const gchar *subtype, + const gchar *format, + ...); +void hg_logv (HgLogType log_type, + const gchar *subtype, + const gchar *format, + va_list va_args); + + +G_END_DECLS + +#endif /* __HG_LOG_H__ */ diff --git a/hieroglyph/hgmem.c b/hieroglyph/hgmem.c index b6514bd..c4c4637 100644 --- a/hieroglyph/hgmem.c +++ b/hieroglyph/hgmem.c @@ -30,6 +30,7 @@ #include <unistd.h> #include "hgmem.h" #include "hgallocator-private.h" +#include "hglog.h" #define VTABLE_TREE_N_NODE 3 @@ -183,7 +184,7 @@ hg_mem_init(void) if (!_hg_object_vtable_tree) { _hg_object_vtable_tree = g_hash_table_new(NULL, g_direct_equal); if (_hg_object_vtable_tree == NULL) { - g_warning("Failed to initialize VTable tree."); + hg_log_warning("Failed to initialize VTable tree."); return; } _hg_object_vtable_array = g_ptr_array_new(); @@ -523,7 +524,7 @@ hg_mem_free(gpointer data) hg_mem_get_object__inline(data, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p is given to be freed.", data); + hg_log_warning("[BUG] Invalid object %p is given to be freed.", data); return FALSE; } else { const HgObjectVTable const *vtable; @@ -555,7 +556,7 @@ hg_mem_resize(gpointer data, hg_mem_get_object__inline(data, obj); if (obj == NULL) { - g_warning("Invalid object %p was about to be resized.", data); + hg_log_warning("Invalid object %p was about to be resized.", data); return NULL; } @@ -571,7 +572,7 @@ hg_mem_get_object_size(gpointer data) hg_mem_get_object__inline(data, obj); if (obj == NULL) { - g_warning("Invalid object %p was about to get an object size.", data); + hg_log_warning("Invalid object %p was about to get an object size.", data); return 0; } @@ -763,8 +764,8 @@ hg_object_get_vtable(HgObject *object) return NULL; } if (id > _hg_object_vtable_array->len) { - g_warning("[BUG] Invalid vtable ID found: %p id: %d latest id: %u\n", - object, id, _hg_object_vtable_array->len); + hg_log_warning("[BUG] Invalid vtable ID found: %p id: %d latest id: %u\n", + object, id, _hg_object_vtable_array->len); return NULL; } @@ -791,7 +792,7 @@ hg_object_set_vtable(HgObject *object, g_hash_table_insert(_hg_object_vtable_tree, (gpointer)vtable, GUINT_TO_POINTER (id)); } if (id > 255) { - g_warning("[BUG] Invalid vtable ID found in tree: %p id %u\n", object, id); + hg_log_warning("[BUG] Invalid vtable ID found in tree: %p id %u\n", object, id); id = 0; } HG_OBJECT_SET_VTABLE_ID (object, id); diff --git a/hieroglyph/hgpage.c b/hieroglyph/hgpage.c index 74fd0ac..45d2ef7 100644 --- a/hieroglyph/hgpage.c +++ b/hieroglyph/hgpage.c @@ -26,6 +26,7 @@ #endif #include "hgpage.h" +#include "hglog.h" /* @@ -60,7 +61,7 @@ hg_page_new_with_pagesize(HgPageSize size) gdouble width, height; if (!hg_page_get_size(size, &width, &height)) { - g_warning("Failed to get a paper size."); + hg_log_warning("Failed to get a paper size."); return NULL; } return hg_page_new_with_size(width, height); @@ -74,7 +75,7 @@ hg_page_new_with_size(gdouble width, retval = _hg_page_new(); if (retval == NULL) { - g_warning("Failed to create a page object."); + hg_log_warning("Failed to create a page object."); return NULL; } retval->width = width; @@ -217,7 +218,7 @@ hg_page_get_size(HgPageSize size, *height = 148; break; default: - g_warning("Unknown page size type %d", size); + hg_log_warning("Unknown page size type %d", size); *width = 0; *height = 0; return FALSE; diff --git a/hieroglyph/hgpath.c b/hieroglyph/hgpath.c index 9a5c98c..fd4e7fd 100644 --- a/hieroglyph/hgpath.c +++ b/hieroglyph/hgpath.c @@ -28,6 +28,7 @@ #include <math.h> #include <string.h> #include "hgpath.h" +#include "hglog.h" #include "hgmem.h" @@ -74,7 +75,7 @@ _hg_path_node_real_set_flags(gpointer data, if (node->next) { hg_mem_get_object__inline(node->next, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgPathNode", node->next); + hg_log_warning("[BUG] Invalid object %p to be marked: HgPathNode", node->next); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -126,7 +127,7 @@ _hg_path_real_set_flags(gpointer data, if (path->node) { hg_mem_get_object__inline(path->node, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgPathNode (in HgPath)", path->node); + hg_log_warning("[BUG] Invalid object %p to be marked: HgPathNode (in HgPath)", path->node); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -333,18 +334,18 @@ hg_path_compute_current_point(HgPath *path, switch (node->type) { case HG_PATH_CURVETO: if (!currentpoint) { - g_warning("[BUG] no current point found in %d.", node->type); + hg_log_warning("[BUG] no current point found in %d.", node->type); return FALSE; } if (node->next == NULL || node->next->next == NULL) { - g_warning("[BUG] Invalid path found in %d.", node->type); + hg_log_warning("[BUG] Invalid path found in %d.", node->type); return FALSE; } node = node->next->next; case HG_PATH_LINETO: if (!currentpoint) { - g_warning("[BUG] no current point found in %d.", node->type); + hg_log_warning("[BUG] no current point found in %d.", node->type); return FALSE; } case HG_PATH_MOVETO: @@ -355,14 +356,14 @@ hg_path_compute_current_point(HgPath *path, case HG_PATH_RCURVETO: if (node->next == NULL || node->next->next == NULL) { - g_warning("[BUG] Invalid path found in %d.", node->type); + hg_log_warning("[BUG] Invalid path found in %d.", node->type); return FALSE; } node = node->next->next; case HG_PATH_RMOVETO: case HG_PATH_RLINETO: if (!currentpoint) { - g_warning("[BUG] no current point found in %d.", node->type); + hg_log_warning("[BUG] no current point found in %d.", node->type); return FALSE; } *x = *x + node->x; @@ -371,7 +372,7 @@ hg_path_compute_current_point(HgPath *path, case HG_PATH_ARC: if (node->next == NULL || node->next->next == NULL) { - g_warning("[BUG] Invalid path found in %d.\n", node->type); + hg_log_warning("[BUG] Invalid path found in %d.\n", node->type); return FALSE; } G_STMT_START { @@ -391,7 +392,7 @@ hg_path_compute_current_point(HgPath *path, case HG_PATH_MATRIX: break; default: - g_warning("[BUG] Unknown path %d was given.", node->type); + hg_log_warning("[BUG] Unknown path %d was given.", node->type); return FALSE; } } @@ -495,7 +496,7 @@ hg_path_get_bbox(HgPath *path, case HG_PATH_ARC: flag = TRUE; if (node->next == NULL || node->next->next == NULL) { - g_warning("[BUG] Invalid path for arc."); + hg_log_warning("[BUG] Invalid path for arc."); break; } G_STMT_START { @@ -543,7 +544,7 @@ hg_path_get_bbox(HgPath *path, /* this isn't used to calculate bbox at all */ break; default: - g_warning("[BUG] Unknown path type %d to examine current bbox.", node->type); + hg_log_warning("[BUG] Unknown path type %d to examine current bbox.", node->type); return FALSE; } } diff --git a/hieroglyph/hgplugins.c b/hieroglyph/hgplugins.c index 692f4cd..8047535 100644 --- a/hieroglyph/hgplugins.c +++ b/hieroglyph/hgplugins.c @@ -28,6 +28,7 @@ #include <string.h> #include "hgplugins.h" #include "hgmem.h" +#include "hglog.h" static void _hg_plugin_real_free (gpointer data); @@ -88,7 +89,7 @@ _hg_plugin_load(HgMemPool *pool, #define _CHECK_SYMBOL(_sym) \ g_module_symbol(module, #_sym, &(_sym)); \ if ((_sym) == NULL) { \ - g_warning(g_module_error()); \ + hg_log_warning(g_module_error()); \ g_module_close(module); \ return NULL; \ } @@ -100,11 +101,11 @@ _hg_plugin_load(HgMemPool *pool, /* initialize a plugin and get a HgPlugin instance */ retval = ((HgPluginNewFunc)plugin_new) (pool); if (retval == NULL) { - g_warning("Failed to create an instance of the plugin `%s'", filename); + hg_log_warning("Failed to create an instance of the plugin `%s'", filename); g_module_close(module); } else if (retval->version < HG_PLUGIN_VERSION || retval->vtable == NULL) { - g_warning("`%s' is an invalid plugin.", filename); + hg_log_warning("`%s' is an invalid plugin.", filename); g_module_close(module); retval = NULL; } else { @@ -112,7 +113,7 @@ _hg_plugin_load(HgMemPool *pool, } #ifdef DEBUG_PLUGIN } else { - g_warning(g_module_error()); + hg_log_warning(g_module_error()); #endif } @@ -134,7 +135,7 @@ hg_plugin_new(HgMemPool *pool, sizeof (HgPlugin), HG_FL_HGOBJECT | HG_FL_COMPLEX); if (retval == NULL) { - g_warning("Failed to create a plugin."); + hg_log_warning("Failed to create a plugin."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -175,7 +176,7 @@ hg_plugin_open(HgMemPool *pool, modulename = g_strdup_printf("libdevice-%s.so", realname); break; default: - g_warning("Unknown plugin type: %d", type); + hg_log_warning("Unknown plugin type: %d", type); return NULL; } if ((modpath = g_getenv("HIEROGLYPH_PLUGIN_PATH")) != NULL) { @@ -213,12 +214,12 @@ hg_plugin_open(HgMemPool *pool, g_free(fullmodname); } if (retval == NULL) { - g_warning("No `%s' %s plugin module found.", realname, typenames[type]); + hg_log_warning("No `%s' %s plugin module found.", realname, typenames[type]); } else { /* initialize a plugin */ if (retval->vtable->init == NULL || !retval->vtable->init()) { - g_warning("Failed to initialize a plugin `%s'", realname); + hg_log_warning("Failed to initialize a plugin `%s'", realname); retval = NULL; } } @@ -243,8 +244,8 @@ hg_plugin_load(HgPlugin *plugin, if (retval) { plugin->is_loaded = TRUE; } else { - g_warning("Failed to load a plugin `%s'", - g_module_name(plugin->module)); + hg_log_warning("Failed to load a plugin `%s'", + g_module_name(plugin->module)); } return retval; diff --git a/hieroglyph/hgrender.c b/hieroglyph/hgrender.c index 51d4c77..4148b65 100644 --- a/hieroglyph/hgrender.c +++ b/hieroglyph/hgrender.c @@ -27,6 +27,7 @@ #include <string.h> #include "hgrender.h" +#include "hglog.h" #include "hgmem.h" @@ -81,7 +82,7 @@ _hg_render_fill_real_set_flags(gpointer data, hg_mem_get_object__inline(render->u.fill.path, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgRenderFill.", render->u.fill.path); + hg_log_warning("[BUG] Invalid object %p to be marked: HgRenderFill.", render->u.fill.path); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -109,14 +110,14 @@ _hg_render_stroke_real_set_flags(gpointer data, hg_mem_get_object__inline(render->u.stroke.path, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgRenderStroke->path.", render->u.stroke.path); + hg_log_warning("[BUG] Invalid object %p to be marked: HgRenderStroke->path.", render->u.stroke.path); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); } hg_mem_get_object__inline(render->u.stroke.dashline_pattern, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: HgRenderStroke->dashline_pattern.", render->u.stroke.dashline_pattern); + hg_log_warning("[BUG] Invalid object %p to be marked: HgRenderStroke->dashline_pattern.", render->u.stroke.dashline_pattern); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); diff --git a/hieroglyph/hgstack.c b/hieroglyph/hgstack.c index 294a705..489e2d7 100644 --- a/hieroglyph/hgstack.c +++ b/hieroglyph/hgstack.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include "hgstack.h" +#include "hglog.h" #include "hgmem.h" #include "hgfile.h" #include "hgstring.h" @@ -82,7 +83,7 @@ _hg_stack_real_set_flags(gpointer data, for (list = stack->stack; list != NULL; list = g_list_next(list)) { hg_mem_get_object__inline(list->data, obj); if (obj == NULL) { - g_warning("Invalid object %p to be marked: HgValueNode in stack.", list->data); + hg_log_warning("Invalid object %p to be marked: HgValueNode in stack.", list->data); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_set_flags__inline(obj, flags, TRUE); @@ -117,7 +118,7 @@ _hg_stack_real_dup(gpointer data) retval = hg_stack_new(obj->pool, stack->max_depth); if (retval == NULL) { - g_warning("Failed to duplicate a stack."); + hg_log_warning("Failed to duplicate a stack."); return NULL; } retval->stack = g_list_copy(stack->stack); @@ -141,7 +142,7 @@ hg_stack_new(HgMemPool *pool, retval = hg_mem_alloc_with_flags(pool, sizeof (HgStack), HG_FL_HGOBJECT); if (retval == NULL) { - g_warning("Failed to create a stack."); + hg_log_warning("Failed to create a stack."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); diff --git a/hieroglyph/hgstring.c b/hieroglyph/hgstring.c index 54a9fa8..c51aa3d 100644 --- a/hieroglyph/hgstring.c +++ b/hieroglyph/hgstring.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <string.h> #include "hgstring.h" +#include "hglog.h" #include "hgmem.h" #define HG_STRING_ALLOC_SIZE 256 @@ -76,7 +77,7 @@ _hg_string_real_set_flags(gpointer data, flags &= ~HG_FL_RESTORABLE; hg_mem_get_object__inline(string->strings, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: String", string->strings); + hg_log_warning("[BUG] Invalid object %p to be marked: String", string->strings); } else { #ifdef DEBUG_GC G_STMT_START { @@ -173,7 +174,7 @@ hg_string_new(HgMemPool *pool, sizeof (HgString), HG_FL_HGOBJECT | HG_FL_COMPLEX); if (retval == NULL) { - g_warning("Failed to create a string."); + hg_log_warning("Failed to create a string."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -195,7 +196,7 @@ hg_string_new(HgMemPool *pool, retval->current = retval->strings; if (retval->strings == NULL) { hg_mem_free(retval); - g_warning("Failed to create a string."); + hg_log_warning("Failed to create a string."); return NULL; } @@ -251,7 +252,7 @@ hg_string_append_c(HgString *string, gpointer p = hg_mem_resize(string->strings, string->allocated_size + HG_STRING_ALLOC_SIZE + 1); if (p == NULL) { - g_warning("Failed to resize a string."); + hg_log_warning("Failed to resize a string."); return FALSE; } string->current = string->strings = p; @@ -286,7 +287,7 @@ hg_string_append(HgString *string, gpointer p = hg_mem_resize(string->strings, n_unit * HG_STRING_ALLOC_SIZE); if (p == NULL) { - g_warning("Failed to resize a string."); + hg_log_warning("Failed to resize a string."); return FALSE; } string->current = string->strings = p; @@ -374,7 +375,7 @@ hg_string_fix_string_size(HgString *string) p = hg_mem_resize(string->strings, string->length + 1); if (p == NULL) { - g_warning("Failed to resize a string."); + hg_log_warning("Failed to resize a string."); return FALSE; } string->strings = p; diff --git a/hieroglyph/hgtypes.h b/hieroglyph/hgtypes.h index 88d554d..f9da6a9 100644 --- a/hieroglyph/hgtypes.h +++ b/hieroglyph/hgtypes.h @@ -45,6 +45,7 @@ typedef struct _HieroGlyphLineEditVTable HgLineEditVTable; /* hglist.h */ typedef struct _HieroGlyphList HgList; typedef struct _HieroGlyphListIter *HgListIter; +/* hglog.h */ /* hgmem.h */ typedef struct _HieroGlyphAllocatorVTable HgAllocatorVTable; typedef struct _HieroGlyphAllocator HgAllocator; @@ -99,14 +100,14 @@ typedef struct _HieroGlyphDevice HgDevice; typedef gboolean (*HgCompareFunc) (gconstpointer a, gconstpointer b); -typedef gboolean (*HgTraverseFunc) (gpointer key, - gpointer val, - gpointer data); -typedef void (*HgDebugFunc) (gpointer data); +typedef gboolean (*HgTraverseFunc) (gpointer key, + gpointer val, + gpointer data); +typedef void (*HgDebugFunc) (gpointer data); typedef HgAllocatorVTable * (*HgAllocatorTypeFunc) (void); -typedef HgPlugin * (*HgPluginNewFunc) (HgMemPool *pool); -typedef gboolean (*HgOperatorFunc) (HgOperator *op, - gpointer vm); +typedef HgPlugin * (*HgPluginNewFunc) (HgMemPool *pool); +typedef gboolean (*HgOperatorFunc) (HgOperator *op, + gpointer vm); typedef enum { HG_MEM_GLOBAL = 1 << 0, /* without this, that means the local pool */ @@ -213,6 +214,14 @@ typedef enum { HG_FILE_POS_END = SEEK_END } HgFilePosType; +/* hglog.h */ +typedef enum { + HG_LOG_TYPE_INFO = 0, + HG_LOG_TYPE_DEBUG = 1, + HG_LOG_TYPE_WARNING = 2, + HG_LOG_TYPE_ERROR = 3, +} HgLogType; + typedef enum { HG_PAGE_4A0 = 1, HG_PAGE_2A0 = 2, diff --git a/hieroglyph/hgvaluenode.c b/hieroglyph/hgvaluenode.c index 3466b81..d06ca72 100644 --- a/hieroglyph/hgvaluenode.c +++ b/hieroglyph/hgvaluenode.c @@ -33,6 +33,7 @@ #include "hgbtree.h" #include "hgdict.h" #include "hgfile.h" +#include "hglog.h" #include "hgmem.h" #include "hgstring.h" @@ -70,7 +71,7 @@ _hg_value_node_register_type(const HgValueNodeTypeInfo *info) g_return_val_if_fail (__hg_value_node_is_initialized, FALSE); if (hg_btree_find(__hg_value_node_type_tree, GUINT_TO_POINTER (info->type_id))) { - g_warning("type_id %d already registered.", info->type_id); + hg_log_warning("type_id %d already registered.", info->type_id); return FALSE; } hg_btree_add(__hg_value_node_type_tree, @@ -104,9 +105,9 @@ _hg_value_node_real_set_flags(gpointer data, if (((HgValueNodePointer *)node)->value) { hg_mem_get_object__inline(((HgValueNodePointer *)node)->value, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p with node type %d", - ((HgValueNodePointer *)node)->value, - HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] Invalid object %p with node type %d", + ((HgValueNodePointer *)node)->value, + HG_VALUE_GET_VALUE_TYPE (node)); } } break; @@ -114,7 +115,7 @@ _hg_value_node_real_set_flags(gpointer data, case HG_TYPE_VALUE_MARK: break; default: - g_warning("Unknown node type %d to set flags", HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("Unknown node type %d to set flags", HG_VALUE_GET_VALUE_TYPE (node)); break; } @@ -164,7 +165,7 @@ _hg_value_node_real_relocate(gpointer data, case HG_TYPE_VALUE_MARK: break; default: - g_warning("Unknown node type %d to be relocated", HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("Unknown node type %d to be relocated", HG_VALUE_GET_VALUE_TYPE (node)); break; } } @@ -185,7 +186,7 @@ _hg_value_node_real_dup(gpointer data) } retval = hg_value_node_new(obj->pool, HG_VALUE_GET_VALUE_TYPE (node)); if (retval == NULL) { - g_warning("Failed to duplicate a node."); + hg_log_warning("Failed to duplicate a node."); return NULL; } HG_OBJECT_SET_STATE (&retval->object, HG_OBJECT_GET_STATE (&node->object)); @@ -224,7 +225,7 @@ _hg_value_node_real_dup(gpointer data) HG_VALUE_SET_PLUGIN (retval, HG_VALUE_GET_PLUGIN (node)); break; default: - g_warning("Unknown node type %d to be duplicated", HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("Unknown node type %d to be duplicated", HG_VALUE_GET_VALUE_TYPE (node)); hg_mem_free(retval); return NULL; } @@ -257,7 +258,7 @@ _hg_value_node_real_copy(gpointer data) } retval = hg_value_node_new(obj->pool, HG_VALUE_GET_VALUE_TYPE (node)); if (retval == NULL) { - g_warning("Failed to duplicate a node."); + hg_log_warning("Failed to duplicate a node."); return NULL; } HG_OBJECT_SET_STATE (&retval->object, HG_OBJECT_GET_STATE (&node->object)); @@ -296,7 +297,7 @@ _hg_value_node_real_copy(gpointer data) _copy_object (retval, PLUGIN, HG_VALUE_GET_PLUGIN (node)); break; default: - g_warning("Unknown node type %d to be duplicated", HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("Unknown node type %d to be duplicated", HG_VALUE_GET_VALUE_TYPE (node)); hg_mem_free(retval); return NULL; } @@ -413,8 +414,8 @@ _hg_value_node_real_to_string(gpointer data) hg_string_append(retval, "-mark-", -1); break; default: - g_warning("Unknown node type %d to be converted to string.", - HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("Unknown node type %d to be converted to string.", + HG_VALUE_GET_VALUE_TYPE (node)); break; } if (str) @@ -508,8 +509,8 @@ hg_value_node_get_type_name(guint type_id) if ((info = hg_btree_find(__hg_value_node_type_tree, GUINT_TO_POINTER (type_id))) == NULL) { - g_warning("Unknown type ID %d. Failed to get a type name.", - type_id); + hg_log_warning("Unknown type ID %d. Failed to get a type name.", + type_id); return NULL; } @@ -528,13 +529,13 @@ hg_value_node_new(HgMemPool *pool, if ((info = hg_btree_find(__hg_value_node_type_tree, GUINT_TO_POINTER (type_id))) == NULL) { - g_warning("Unknown type ID %d. Failed to create a HgValueNode.", type_id); + hg_log_warning("Unknown type ID %d. Failed to create a HgValueNode.", type_id); return NULL; } retval = hg_mem_alloc_with_flags(pool, info->struct_size, HG_FL_HGOBJECT | HG_FL_RESTORABLE); if (retval == NULL) { - g_warning("Failed to create a node."); + hg_log_warning("Failed to create a node."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -608,8 +609,8 @@ hg_value_node_get_hash(const HgValueNode *node) retval = _get_hash(node, PLUGIN); break; default: - g_warning("[BUG] Unknown node type %d to generate hash", - HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] Unknown node type %d to generate hash", + HG_VALUE_GET_VALUE_TYPE (node)); break; } @@ -671,8 +672,8 @@ hg_value_node_compare(const HgValueNode *a, retval = TRUE; break; default: - g_warning("[BUG] Unknown node type is given to compare: %d", - HG_VALUE_GET_VALUE_TYPE (a)); + hg_log_warning("[BUG] Unknown node type is given to compare: %d", + HG_VALUE_GET_VALUE_TYPE (a)); break; } @@ -739,8 +740,8 @@ hg_value_node_compare_content(const HgValueNode *a, retval = TRUE; break; default: - g_warning("[BUG] Unknown node type is given to compare: %d", - HG_VALUE_GET_VALUE_TYPE (a)); + hg_log_warning("[BUG] Unknown node type is given to compare: %d", + HG_VALUE_GET_VALUE_TYPE (a)); break; } diff --git a/hieroglyph/iarray.c b/hieroglyph/iarray.c index 2391746..1fdd8e0 100644 --- a/hieroglyph/iarray.c +++ b/hieroglyph/iarray.c @@ -26,6 +26,7 @@ #endif #include "iarray.h" +#include "hglog.h" #include "hgmem.h" #define HG_INT_ARRAY_ALLOC_SIZE 256 @@ -67,7 +68,7 @@ _hg_int_array_real_set_flags(gpointer data, if (iarray->arrays) { hg_mem_get_object__inline(iarray->arrays, obj); if (obj == NULL) { - g_warning("[BUG] Invalid object %p to be marked: IntArray", iarray->arrays); + hg_log_warning("[BUG] Invalid object %p to be marked: IntArray", iarray->arrays); } else { if (!hg_mem_is_flags__inline(obj, flags)) hg_mem_add_flags__inline(obj, flags, TRUE); @@ -146,7 +147,7 @@ hg_int_array_append(HgIntArray *iarray, sizeof (gint32) * (iarray->allocated_arrays + HG_INT_ARRAY_ALLOC_SIZE)); if (p == NULL) { - g_warning("Failed to resize an int array."); + hg_log_warning("Failed to resize an int array."); return FALSE; } else { iarray->arrays = p; diff --git a/hieroglyph/ibtree.c b/hieroglyph/ibtree.c index 991868d..9ac41f4 100644 --- a/hieroglyph/ibtree.c +++ b/hieroglyph/ibtree.c @@ -26,6 +26,7 @@ #endif #include "ibtree.h" +#include "hglog.h" static HgBTreePage *hg_btree_page_new (HgBTree *tree); @@ -196,7 +197,7 @@ hg_btree_page_blance(HgBTree *tree, size = tree->page_size + 1; new = hg_btree_page_new(tree); if (new == NULL) { - g_warning("Failed to allocate a memory."); + hg_log_warning("Failed to allocate a memory."); return; } for (i = size + 1; i <= tree->page_size * 2; i++) { diff --git a/hieroglyph/ilist.c b/hieroglyph/ilist.c index 1a0e215..95fd76e 100644 --- a/hieroglyph/ilist.c +++ b/hieroglyph/ilist.c @@ -26,6 +26,7 @@ #endif #include "ilist.h" +#include "hglog.h" /* * Most code are duplicate from HgList. @@ -95,7 +96,7 @@ _hg_list_get_last_node(HgList *list) if (hg_list_next(tmp) != NULL || hg_list_previous(tmp) != NULL) { /* found incomplete node */ - g_warning("[BUG] incomplete HgList node %p found.", tmp); + hg_log_warning("[BUG] incomplete HgList node %p found.", tmp); } else { /* this can be used as the last node */ return tmp; @@ -109,8 +110,8 @@ _hg_list_get_last_node(HgList *list) /* validate node */ if (tmp == list) { /* detected the circular reference */ - g_warning("[BUG] Circular reference happened without the last node mark: %p", - list); + hg_log_warning("[BUG] Circular reference happened without the last node mark: %p", + list); /* workaround */ return hg_list_previous(list); } @@ -273,7 +274,7 @@ _hg_list_length(HgList *list) /* validate node */ if (l == NULL) { - g_warning("[BUG] no loop detected in HgList %p", list); + hg_log_warning("[BUG] no loop detected in HgList %p", list); } return retval; @@ -319,8 +320,8 @@ _hg_list_remove(HgList *list, /* validate node */ if (l == NULL) { - g_warning("[BUG] no loop detected in HgList %p during removing %p", - list, data); + hg_log_warning("[BUG] no loop detected in HgList %p during removing %p", + list, data); top = list; } else { if (!top) diff --git a/hieroglyph/operator.c b/hieroglyph/operator.c index 4219ec0..7db1742 100644 --- a/hieroglyph/operator.c +++ b/hieroglyph/operator.c @@ -39,6 +39,7 @@ #include "hgdict.h" #include "hgfile.h" #include "hglineedit.h" +#include "hglog.h" #include "hgmatrix.h" #include "hgpath.h" #include "hgstack.h" @@ -1244,7 +1245,7 @@ G_STMT_START i = depth - 3; break; default: - g_warning("Unknown emulation level %d\n", type); + hg_log_warning("Unknown emulation level %d\n", type); break; } if (i < 0) { @@ -3074,7 +3075,7 @@ G_STMT_START break; } } else { - g_warning("unknown open type: %d", file_type); + hg_log_warning("unknown open type: %d", file_type); } if (file == NULL) { _hg_operator_set_error(vm, op, VM_e_VMerror); @@ -6491,8 +6492,8 @@ G_STMT_START break; case HG_TYPE_VALUE_END: default: - g_warning("[BUG] Unknown node type %d was given.", - HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] Unknown node type %d was given.", + HG_VALUE_GET_VALUE_TYPE (node)); _hg_operator_set_error(vm, op, VM_e_typecheck); return retval; @@ -6612,7 +6613,7 @@ G_STMT_START for (i = 0; i < ddepth; i++) { ndict = hg_stack_index(dstack, i); if (!HG_IS_VALUE_DICT (ndict)) { - g_warning("[BUG] Invalid dictionary was in the dictionary stack."); + hg_log_warning("[BUG] Invalid dictionary was in the dictionary stack."); return retval; } dict = HG_VALUE_GET_DICT (ndict); @@ -7517,7 +7518,7 @@ _hg_operator_real_set_flags(gpointer data, hg_mem_get_object__inline(op->name, obj); if (obj == NULL) { - g_warning("Invalid object %p to be marked: HgOperator->name", op->name); + hg_log_warning("Invalid object %p to be marked: HgOperator->name", op->name); } else { #ifdef DEBUG_GC G_STMT_START { @@ -7987,7 +7988,7 @@ hg_operator_new(HgMemPool *pool, retval = hg_mem_alloc_with_flags(pool, sizeof (HgOperator), HG_FL_HGOBJECT); if (retval == NULL) { - g_warning("Failed to create an operator."); + hg_log_warning("Failed to create an operator."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -7997,7 +7998,7 @@ hg_operator_new(HgMemPool *pool, len = strlen(name); retval->name = hg_mem_alloc(pool, len + 1); if (retval->name == NULL) { - g_warning("Failed to create an operator."); + hg_log_warning("Failed to create an operator."); return NULL; } strncpy(retval->name, name, len); @@ -8022,7 +8023,7 @@ hg_operator_init(HgVM *vm) type = hg_vm_get_emulation_level(vm); if (type < VM_EMULATION_LEVEL_1 || type > VM_EMULATION_LEVEL_3) { - g_warning("[BUG] Unknown emulation level %d", type); + hg_log_warning("[BUG] Unknown emulation level %d", type); return FALSE; } diff --git a/hieroglyph/scanner.c b/hieroglyph/scanner.c index 76b7d2e..1d55594 100644 --- a/hieroglyph/scanner.c +++ b/hieroglyph/scanner.c @@ -31,6 +31,7 @@ #include "hgarray.h" #include "hgdict.h" #include "hgfile.h" +#include "hglog.h" #include "hgstring.h" #include "hgvaluenode.h" #include "iarray.h" @@ -312,9 +313,9 @@ _hg_scanner_get_object(HgVM *vm, need_loop = FALSE; } else if (c == '~') { /* ASCII85 encoding */ - g_warning("FIXME: implement me"); + hg_log_warning("FIXME: implement me"); } else { - g_warning("FIXME: implement me"); + hg_log_warning("FIXME: implement me"); hg_file_object_ungetc(file, c); } break; @@ -325,9 +326,9 @@ _hg_scanner_get_object(HgVM *vm, need_loop = FALSE; } else if (c == '~') { /* ASCII85 encoding */ - g_warning("FIXME: implement me"); + hg_log_warning("FIXME: implement me"); } else { - g_warning("FIXME: implement me"); + hg_log_warning("FIXME: implement me"); hg_file_object_ungetc(file, c); } break; @@ -394,7 +395,7 @@ _hg_scanner_get_object(HgVM *vm, was_comment = TRUE; break; default: - g_warning("[BUG] unknown control object %c.", c); + hg_log_warning("[BUG] unknown control object %c.", c); break; } break; @@ -483,7 +484,7 @@ _hg_scanner_get_object(HgVM *vm, } break; default: - g_warning("[BUG] it may be unlikely to appear HG_SCAN_C_NAME in token type %d\n", token_type); + hg_log_warning("[BUG] it may be unlikely to appear HG_SCAN_C_NAME in token type %d\n", token_type); break; } break; @@ -533,7 +534,7 @@ _hg_scanner_get_object(HgVM *vm, case HG_SCAN_C_BINARY: break; default: - g_warning("Unknown character %c(%d)[%d]", c, c, __hg_scanner_token[c]); + hg_log_warning("Unknown character %c(%d)[%d]", c, c, __hg_scanner_token[c]); break; } } @@ -586,7 +587,7 @@ _hg_scanner_get_object(HgVM *vm, default: /* XXX */ if (!was_comment) - g_warning("FIXME: unknown token type %d\n", token_type); + hg_log_warning("FIXME: unknown token type %d\n", token_type); break; } @@ -736,7 +737,7 @@ _hg_scanner_parse_number(HgVM *vm, is_valid = FALSE; break; default: - g_warning("[BUG] it may be unlikely to appear HG_SCAN_C_NAME in token type %d\n", token_type); + hg_log_warning("[BUG] it may be unlikely to appear HG_SCAN_C_NAME in token type %d\n", token_type); is_valid = FALSE; break; } @@ -794,7 +795,7 @@ _hg_scanner_parse_number(HgVM *vm, } break; default: - g_warning("[BUG] it may be unlikely to appear HG_SCAN_C_NUMERAL in token type %d\n", token_type); + hg_log_warning("[BUG] it may be unlikely to appear HG_SCAN_C_NUMERAL in token type %d\n", token_type); goto non_numeral_handler; } break; @@ -822,7 +823,7 @@ _hg_scanner_parse_number(HgVM *vm, intdigits = (guint)log10(di) + 1; if (has_radix) { /* this is unlikely */ - g_warning("[BUG] numeric with radix is going to be the real."); + hg_log_warning("[BUG] numeric with radix is going to be the real."); return FALSE; } if (floatarray) { diff --git a/hieroglyph/version.h.in b/hieroglyph/version.h.in index d185a96..c649c61 100644 --- a/hieroglyph/version.h.in +++ b/hieroglyph/version.h.in @@ -29,7 +29,7 @@ G_BEGIN_DECLS #define HIEROGLYPH_VERSION "@VERSION@" -#define HIEROGLYPH_UUID "de8df9d1-2e02-45db-9c8c-906a0e87d5bb" +#define HIEROGLYPH_UUID "118f9f31-4fa8-45fa-9343-f9c124b0ab6c" const char *__hg_rcsid G_GNUC_UNUSED = "$Rev$"; diff --git a/hieroglyph/vm.c b/hieroglyph/vm.c index f7328c0..516e593 100644 --- a/hieroglyph/vm.c +++ b/hieroglyph/vm.c @@ -37,6 +37,7 @@ #include "hgfile.h" #include "hglineedit.h" #include "hglist.h" +#include "hglog.h" #include "hgplugins.h" #include "hgstack.h" #include "hgstring.h" @@ -432,7 +433,7 @@ hg_vm_new(HgVMEmulationType type) retval = hg_mem_alloc_with_flags(__hg_vm_mem_pool, sizeof (HgVM), HG_FL_HGOBJECT); if (retval == NULL) { - g_warning("Failed to create a virtual machine."); + hg_log_warning("Failed to create a virtual machine."); return NULL; } HG_OBJECT_INIT_STATE (&retval->object); @@ -461,7 +462,7 @@ hg_vm_new(HgVMEmulationType type) (allow_resize ? HG_MEM_RESIZABLE : 0)); g_free(name); if (retval->local_pool == NULL) { - g_warning("Failed to create a local memory pool"); + hg_log_warning("Failed to create a local memory pool"); return NULL; } #ifdef ENABLE_GLOBAL_POOL @@ -473,7 +474,7 @@ hg_vm_new(HgVMEmulationType type) hg_mem_pool_use_global_mode(retval->global_pool, TRUE); g_free(name); if (retval->global_pool == NULL) { - g_warning("Failed to create a global memory pool"); + hg_log_warning("Failed to create a global memory pool"); return NULL; } #else @@ -486,14 +487,14 @@ hg_vm_new(HgVMEmulationType type) (allow_resize ? HG_MEM_RESIZABLE : 0)); g_free(name); if (retval->graphic_pool == NULL) { - g_warning("Failed to create a graphic memory pool"); + hg_log_warning("Failed to create a graphic memory pool"); return NULL; } /* internal use */ retval->name_dict = hg_dict_new(retval->global_pool, 1024); if (retval->name_dict == NULL) { - g_warning("Failed to create a name dict."); + hg_log_warning("Failed to create a name dict."); return NULL; } hg_mem_add_root_node(retval->global_pool, retval->name_dict); @@ -513,7 +514,7 @@ hg_vm_new(HgVMEmulationType type) if (retval->ostack == NULL || retval->estack == NULL || retval->dstack == NULL) { - g_warning("Failed to create stacks."); + hg_log_warning("Failed to create stacks."); return NULL; } hg_mem_add_root_node(retval->local_pool, retval->ostack); @@ -531,7 +532,7 @@ hg_vm_new(HgVMEmulationType type) retval->statusdict == NULL || retval->serverdict == NULL || retval->font == NULL) { - g_warning("Failed to create local dictionaries."); + hg_log_warning("Failed to create local dictionaries."); return NULL; } hg_mem_add_root_node(retval->local_pool, retval->errordict); @@ -545,7 +546,7 @@ hg_vm_new(HgVMEmulationType type) retval->globalfont = hg_dict_new(retval->global_pool, 128); if (retval->systemdict == NULL || retval->globalfont == NULL) { - g_warning("Failed to create global dictionaries."); + hg_log_warning("Failed to create global dictionaries."); return NULL; } hg_mem_add_root_node(retval->global_pool, retval->systemdict); @@ -720,7 +721,7 @@ hg_vm_is_global_object(HgVM *vm, retval = (vm->local_pool != obj->pool); break; default: - g_warning("Failed to consider if the object is a global object due to the unknown type ID: %d", HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("Failed to consider if the object is a global object due to the unknown type ID: %d", HG_VALUE_GET_VALUE_TYPE (node)); break; } @@ -779,7 +780,7 @@ hg_vm_get_io(HgVM *vm, case VM_IO_STDERR: return vm->stderr; default: - g_warning("Unknown I/O type %d", type); + hg_log_warning("Unknown I/O type %d", type); break; } @@ -807,7 +808,7 @@ hg_vm_set_io(HgVM *vm, vm->stderr = file; break; default: - g_warning("Unknown I/O type %d", type); + hg_log_warning("Unknown I/O type %d", type); break; } } @@ -841,7 +842,7 @@ hg_vm_load_plugin(HgVM *vm, g_return_val_if_fail (filename != NULL, FALSE); if (hg_dict_lookup_with_string(vm->plugin_table, filename) != NULL) { - g_warning("`%s' plugin is already loaded.", filename); + hg_log_warning("`%s' plugin is already loaded.", filename); return FALSE; } plugin = hg_plugin_open(vm->local_pool, filename, HG_PLUGIN_EXTENSION); @@ -878,7 +879,7 @@ hg_vm_unload_plugin(HgVM *vm, g_return_val_if_fail (filename != NULL, FALSE); if ((val = hg_dict_lookup_with_string(vm->plugin_table, filename)) == NULL) { - g_warning("`%s' plugin isn't yet loaded.", filename); + hg_log_warning("`%s' plugin isn't yet loaded.", filename); return FALSE; } @@ -1138,9 +1139,9 @@ hg_vm_set_error(HgVM *vm, } hs2 = hg_object_to_string((HgObject *)errnode); if (enode == NULL) { - g_warning("Multiple errors occurred.\n prevoius error: unknown or this happened before set /errorname in %s\n current error: %s in %s\n", name, HG_VALUE_GET_NAME (__hg_vm_errorname[error]), hg_string_get_string(hs2)); + hg_log_warning("Multiple errors occurred.\n prevoius error: unknown or this happened before set /errorname in %s\n current error: %s in %s\n", name, HG_VALUE_GET_NAME (__hg_vm_errorname[error]), hg_string_get_string(hs2)); } else { - g_warning("Multiple errors occurred.\n previous error: %s in %s\n current error: %s in %s\n", HG_VALUE_GET_NAME (enode), name, HG_VALUE_GET_NAME (__hg_vm_errorname[error]), hg_string_get_string(hs2)); + hg_log_warning("Multiple errors occurred.\n previous error: %s in %s\n current error: %s in %s\n", HG_VALUE_GET_NAME (enode), name, HG_VALUE_GET_NAME (__hg_vm_errorname[error]), hg_string_get_string(hs2)); } if (p) g_free(p); @@ -1154,7 +1155,7 @@ hg_vm_set_error(HgVM *vm, _hg_stack_use_stack_validator(vm->dstack, FALSE); proc = hg_dict_lookup(vm->errordict, __hg_vm_errorname[error]); if (proc == NULL) { - g_warning("[BUG] no error handler for /%s\n", HG_VALUE_GET_NAME (__hg_vm_errorname[error])); + hg_log_warning("[BUG] no error handler for /%s\n", HG_VALUE_GET_NAME (__hg_vm_errorname[error])); hg_file_object_printf(vm->stderr, "\nOperand stack:\n"); hg_stack_dump(vm->ostack, vm->stderr); hg_file_object_printf(vm->stderr, "\nExecution stack:\n"); @@ -1222,8 +1223,8 @@ hg_vm_set_error_from_file(HgVM *vm, break; default: strerror_r(hg_file_object_get_error(file), buffer, 4096); - g_warning("%s: need to support errno %d\n %s\n", - __FUNCTION__, hg_file_object_get_error(file), buffer); + hg_log_warning("%s: need to support errno %d\n %s\n", + __FUNCTION__, hg_file_object_get_error(file), buffer); break; } hg_file_object_clear_error(file); @@ -1274,8 +1275,8 @@ hg_vm_main(HgVM *vm) case HG_TYPE_VALUE_DICT: case HG_TYPE_VALUE_NULL: case HG_TYPE_VALUE_MARK: - g_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", - __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", + __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); hg_stack_pop(vm->estack); retval = hg_stack_push(vm->ostack, node); if (!retval) { @@ -1308,8 +1309,8 @@ hg_vm_main(HgVM *vm) _hg_vm_set_error(vm, file, VM_e_stackoverflow, FALSE); } } else { - g_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", - __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", + __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); hg_stack_pop(vm->estack); retval = hg_stack_push(vm->ostack, node); if (!retval) { @@ -1333,8 +1334,8 @@ hg_vm_main(HgVM *vm) hg_object_set_state((HgObject *)node, state); retval = hg_stack_push(vm->estack, node); } else { - g_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", - __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", + __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); hg_stack_pop(vm->estack); retval = hg_stack_push(vm->ostack, node); } @@ -1366,8 +1367,8 @@ hg_vm_main(HgVM *vm) } } } else { - g_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", - __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", + __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); hg_stack_pop(vm->estack); retval = hg_stack_push(vm->ostack, node); if (!retval) { @@ -1412,8 +1413,8 @@ hg_vm_main(HgVM *vm) } } } else { - g_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", - __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] %s: an object (node type %d) which isn't actually executable, was pushed into the estack.", + __FUNCTION__, HG_VALUE_GET_VALUE_TYPE (node)); hg_stack_pop(vm->estack); retval = hg_stack_push(vm->ostack, node); if (!retval) { @@ -1422,13 +1423,13 @@ hg_vm_main(HgVM *vm) } break; default: - g_warning("[BUG] Unknown node type %d was given into the estack.", - HG_VALUE_GET_VALUE_TYPE (node)); + hg_log_warning("[BUG] Unknown node type %d was given into the estack.", + HG_VALUE_GET_VALUE_TYPE (node)); hg_stack_pop(vm->estack); break; } if (!retval && !hg_vm_has_error(vm)) { - g_warning("[BUG] probably unknown error happened."); + hg_log_warning("[BUG] probably unknown error happened."); break; } } diff --git a/plugins/debug/debug-main.c b/plugins/debug/debug-main.c index 7572295..c7ce966 100644 --- a/plugins/debug/debug-main.c +++ b/plugins/debug/debug-main.c @@ -26,6 +26,7 @@ #endif #include <hieroglyph/hgdict.h> +#include <hieroglyph/hglog.h> #include <hieroglyph/hgmem.h> #include <hieroglyph/hgplugins.h> #include <hieroglyph/hgstack.h> @@ -157,7 +158,7 @@ plugin_load(HgPlugin *plugin, g_return_val_if_fail (vm != NULL, FALSE); if (plugin->user_data != NULL) { - g_warning("already loaded."); + hg_log_warning("already loaded."); return FALSE; } systemdict = hg_vm_get_dict_systemdict(vm); @@ -187,7 +188,7 @@ plugin_unload(HgPlugin *plugin, g_return_val_if_fail (vm != NULL, FALSE); if (plugin->user_data != NULL) { - g_warning("not yet loaded."); + hg_log_warning("not yet loaded."); return FALSE; } diff --git a/plugins/libedit/libedit-main.c b/plugins/libedit/libedit-main.c index 2dae288..8a26cac 100644 --- a/plugins/libedit/libedit-main.c +++ b/plugins/libedit/libedit-main.c @@ -33,6 +33,7 @@ #include <hieroglyph/hgdict.h> #include <hieroglyph/hgfile.h> #include <hieroglyph/hglineedit.h> +#include <hieroglyph/hglog.h> #include <hieroglyph/hgmem.h> #include <hieroglyph/hgplugins.h> #include <hieroglyph/hgstack.h> @@ -286,7 +287,7 @@ plugin_load(HgPlugin *plugin, g_return_val_if_fail (vm != NULL, FALSE); if (plugin->user_data != NULL) { - g_warning("already loaded."); + hg_log_warning("already loaded."); return FALSE; } plugin->user_data = hg_vm_get_line_editor(vm); @@ -328,7 +329,7 @@ plugin_unload(HgPlugin *plugin, g_return_val_if_fail (vm != NULL, FALSE); if (plugin->user_data != NULL) { - g_warning("not yet loaded."); + hg_log_warning("not yet loaded."); return FALSE; } hg_vm_set_line_editor(vm, plugin->user_data); diff --git a/plugins/test/test-main.c b/plugins/test/test-main.c index 679766c..7284b74 100644 --- a/plugins/test/test-main.c +++ b/plugins/test/test-main.c @@ -28,6 +28,7 @@ #include <hieroglyph/hgarray.h> #include <hieroglyph/hgdict.h> #include <hieroglyph/hgfile.h> +#include <hieroglyph/hglog.h> #include <hieroglyph/hgmem.h> #include <hieroglyph/hgplugins.h> #include <hieroglyph/hgstack.h> @@ -244,7 +245,7 @@ plugin_load(HgPlugin *plugin, g_return_val_if_fail (vm != NULL, FALSE); if (plugin->user_data != NULL) { - g_warning("already loaded."); + hg_log_warning("already loaded."); return FALSE; } systemdict = hg_vm_get_dict_systemdict(vm); @@ -277,7 +278,7 @@ plugin_unload(HgPlugin *plugin, g_return_val_if_fail (vm != NULL, FALSE); if (plugin->user_data != NULL) { - g_warning("not yet loaded."); + hg_log_warning("not yet loaded."); return FALSE; } |