[macruby-changes] [539] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Sat Aug 30 22:21:23 PDT 2008
Revision: 539
http://trac.macosforge.org/projects/ruby/changeset/539
Author: lsansonetti at apple.com
Date: 2008-08-30 22:21:23 -0700 (Sat, 30 Aug 2008)
Log Message:
-----------
improved log facility by printing the file/line and optionally into a file
Modified Paths:
--------------
MacRuby/trunk/debug.h
MacRuby/trunk/eval.c
Modified: MacRuby/trunk/debug.h
===================================================================
--- MacRuby/trunk/debug.h 2008-08-31 04:29:45 UTC (rev 538)
+++ MacRuby/trunk/debug.h 2008-08-31 05:21:23 UTC (rev 539)
@@ -31,12 +31,15 @@
#if ENABLE_DEBUG_LOGGING
# include "vm_core.h"
+# include <libgen.h>
extern bool ruby_dlog_enabled;
-# define DLOG(mod, fmt, args...) \
- if (UNLIKELY(ruby_dlog_enabled)) { \
- printf("%10s ", mod); \
- printf(fmt, ##args); \
- printf("\n"); \
+extern FILE *ruby_dlog_file;
+# define DLOG(mod, fmt, args...) \
+ if (UNLIKELY(ruby_dlog_enabled)) { \
+ fprintf(ruby_dlog_file, "%s:%d %s ", \
+ basename((char *)rb_sourcefile()), rb_sourceline(), mod); \
+ fprintf(ruby_dlog_file, fmt, ##args); \
+ fprintf(ruby_dlog_file, "\n"); \
}
#else
# define DLOG(mod, fmt, args...)
Modified: MacRuby/trunk/eval.c
===================================================================
--- MacRuby/trunk/eval.c 2008-08-31 04:29:45 UTC (rev 538)
+++ MacRuby/trunk/eval.c 2008-08-31 05:21:23 UTC (rev 539)
@@ -56,6 +56,7 @@
#if WITH_OBJC
bool ruby_dlog_enabled = false;
+FILE *ruby_dlog_file = NULL;
#endif
void
@@ -75,8 +76,22 @@
#endif
#if WITH_OBJC
- char *s = getenv("MACRUBY_DEBUG");
+ char *s;
+
+ s = getenv("MACRUBY_DEBUG");
ruby_dlog_enabled = !(s == NULL || *s == '0');
+ s = getenv("MACRUBY_DEBUG_FILE");
+ if (s == NULL) {
+ ruby_dlog_file = stderr;
+ }
+ else {
+ ruby_dlog_file = fopen(s, "w");
+ if (ruby_dlog_file == NULL) {
+ fprintf(stderr, "cannot open macruby debug file `%s'",
+ strerror(errno));
+ ruby_dlog_file = stderr;
+ }
+ }
#endif
Init_stack((void *)&state);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080830/6cf97dba/attachment.html
More information about the macruby-changes
mailing list