Skip to content

Commit

Permalink
Item10328: writeDebug tweaks
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/MongoDBPlugin@13326 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Dec 8, 2011
1 parent 4c9a835 commit 791b2eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
4 changes: 3 additions & 1 deletion lib/Foswiki/Plugins/MongoDBPlugin.pm
Expand Up @@ -604,8 +604,9 @@ sub writeDebug {
my $context = Foswiki::Func::getContext();
my $requestObj = Foswiki::Func::getRequestObject();

( undef, undef, $filename ) = File::Spec->splitpath($filename);
if ( $pack[0] eq 'Foswiki' ) {
$abbr = '..';
$abbr = '::';
shift(@pack);
if ( $pack[0] eq 'Plugins' || $pack[0] eq 'Contrib' ) {
shift(@pack);
Expand All @@ -625,6 +626,7 @@ sub writeDebug {
}
else {
Foswiki::Func::writeDebug($msg);
print STDERR $msg . "\n";
if ( defined $level ) {
ASSERT( $level =~ /^[-]?\d+$/ ) if DEBUG;
if ( $level == -1 ) {
Expand Down
36 changes: 21 additions & 15 deletions lib/Foswiki/Plugins/MongoDBPlugin/HoistMongoDB.pm
Expand Up @@ -40,8 +40,7 @@ sub hoist {
#yes, the simplifier will send an undef parse tree for a query="'1'"
#ASSERT(defined($node)) if DEBUG;

writeDebug( 'node: '
. ( defined($node) ? $node->stringify() : 'undef' ) )
writeDebug( 'node: ' . ( defined($node) ? $node->stringify() : 'undef' ) )
if MONITOR
or MONITOR_DETAIL;

Expand Down Expand Up @@ -171,8 +170,9 @@ sub _hoist {

die 'node eq undef' unless defined($node);

writeDebug( 'Node is a ' . ref($node) . ": " . $node->stringify())
if MONITOR or MONITOR_DETAIL;
writeDebug( 'Node is a ' . ref($node) . ": " . $node->stringify() )
if MONITOR
or MONITOR_DETAIL;

#forward propogate that we're inside a 'where' - eg lhs[rhs]
#sadly, also need to treat a dot case : preferences[value=12].Red
Expand All @@ -187,9 +187,9 @@ sub _hoist {
if ( defined( $node->{params}[1] )
and ( ref( $node->{params}[1] ) ne '' ) );
}
writeDebug( "At level $level with op "
writeDebug( "$level op: "
. ref( $node->{op} )
. ( $node->{inWhere} ? ' inWhere' : '' ) )
. ( $node->{inWhere} ? ' inWhere' : ' not inWhere' ) )
if MONITOR
or MONITOR_DETAIL;

Expand Down Expand Up @@ -221,7 +221,11 @@ sub _hoist {
if ( not ref( $node->{op} ) ) {

#use Data::Dumper;
writeDebug( 'Node is a ' . ref($node) . ' which is not an op: ' . Dumper($node) ) if MONITOR;
writeDebug( 'Node is a '
. ref($node)
. ' which is not an op: '
. Dumper($node) )
if MONITOR;
return Foswiki::Query::OP_dot::hoistMongoDB( $node->{op}, $node );
}
my $unreality_arity = $node->{op}->{arity};
Expand Down Expand Up @@ -275,7 +279,9 @@ sub _hoist {
}

my $query = _hoist( $node->{params}[0], $level . ' ' );
writeDebug("return 1; did something with an OP_dot node containing an OP_where") if MONITOR;
writeDebug(
"return 1; did something with an OP_dot node containing an OP_where"
) if MONITOR;
return $query;
}
elsif ( ( ref( $node->{params}[0]->{op} ) eq '' )
Expand Down Expand Up @@ -359,7 +365,7 @@ sub _hoist {
}

writeDebug( 'node: ' . $node->stringify() ) if MONITOR;
writeDebug( 'node: ' . Dumper($node)) if MONITOR;
writeDebug( 'node: ' . Dumper($node) ) if MONITOR;

#need to convert to js for lc/uc/length etc :(
# '####need_function'
Expand Down Expand Up @@ -885,10 +891,10 @@ sub hoistMongoDB {
my $op = shift;
my $node = shift;

require Data::Dumper
if Foswiki::Plugins::MongoDBPlugin::HoistMongoDB::MONITOR;
writeDebug( "OP_eq: $node => " . Data::Dumper->Dump( [$node] ) )
if Foswiki::Plugins::MongoDBPlugin::HoistMongoDB::MONITOR;
if (Foswiki::Plugins::MongoDBPlugin::HoistMongoDB::MONITOR) {
require Data::Dumper;
writeDebug( "OP_eq: $node => " . Data::Dumper->Dump( [$node] ) );
}

ASSERT( ref($node) eq 'Foswiki::Query::Node' );
ASSERT( ref( $node->{hoisted0} ) eq '' );
Expand Down Expand Up @@ -1145,10 +1151,10 @@ sub hoistMongoDB {
elsif ( $node->{op} == Foswiki::Infix::Node::NAME ) {

#if we're in a where, this is a bit transmissive
writeDebug( "============================= hoist OP_dot("
writeDebug( " ==== hoist OP_dot("
. $node->{op} . ", "
. $node->{params}[0] . ', '
. ( defined( $node->{inWhere} ) ? 'inwhere' : 'notinwhere' )
. ( defined( $node->{inWhere} ) ? 'inWhere' : 'not inWhere' )
. ")" )
if Foswiki::Plugins::MongoDBPlugin::HoistMongoDB::MONITOR;

Expand Down

0 comments on commit 791b2eb

Please sign in to comment.