Skip to content

Commit c533379

Browse files
committed
#113 use std.experimental.logger
1 parent 064366b commit c533379

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

source/mysql/connection.d

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ module mysql.connection;
44
import std.algorithm;
55
import std.conv;
66
import std.exception;
7+
static if(__traits(compiles, (){ import std.experimental.logger; } )) {
8+
import std.experimental.logger;
9+
}
710
import std.range;
811
import std.socket;
912
import std.string;
@@ -438,6 +441,10 @@ package:
438441

439442
static PlainPhobosSocket defaultOpenSocketPhobos(string host, ushort port)
440443
{
444+
static if(__traits(compiles, (){ import std.experimental.logger; } )) {
445+
sharedLog.tracef("opening phobos socket %s:%s", host, port);
446+
}
447+
441448
auto s = new PlainPhobosSocket();
442449
s.connect(new InternetAddress(host, port));
443450
return s;
@@ -446,7 +453,11 @@ package:
446453
static PlainVibeDSocket defaultOpenSocketVibeD(string host, ushort port)
447454
{
448455
version(Have_vibe_core)
449-
return vibe.core.net.connectTCP(host, port);
456+
{
457+
import vibe.core.log : logDebug;
458+
logDebug("opening vibe-d socket %s:%s", host, port);
459+
return vibe.core.net.connectTCP(host, port);
460+
}
450461
else
451462
assert(0);
452463
}

source/mysql/protocol/comms.d

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import std.algorithm;
2424
import std.conv;
2525
import std.digest.sha;
2626
import std.exception;
27+
static if(__traits(compiles, (){ import std.experimental.logger; } )) {
28+
import std.experimental.logger;
29+
}
30+
2731
import std.range;
2832
import std.variant;
2933

@@ -511,9 +515,19 @@ package(mysql) bool execQueryImpl(Connection conn, ExecQueryImplInfo info, out u
511515

512516
// Send data
513517
if(info.isPrepared)
518+
{
519+
static if(__traits(compiles, (){ import std.experimental.logger; } )) {
520+
sharedLog.tracef("prepared SQL: %s", info.hStmt);
521+
}
522+
514523
ProtocolPrepared.sendCommand(conn, info.hStmt, info.psh, info.inParams, info.psa);
524+
}
515525
else
516526
{
527+
static if(__traits(compiles, (){ import std.experimental.logger; } )) {
528+
sharedLog.tracef("exec query: %s", info.sql);
529+
}
530+
517531
conn.sendCmd(CommandType.QUERY, info.sql);
518532
conn._fieldCount = 0;
519533
}
@@ -525,6 +539,11 @@ package(mysql) bool execQueryImpl(Connection conn, ExecQueryImplInfo info, out u
525539
{
526540
conn.resetPacket();
527541
auto okp = OKErrorPacket(packet);
542+
543+
static if(__traits(compiles, (){ import std.experimental.logger; } )) {
544+
sharedLog.errorf("packet error: %s %s", okp.error, okp.message);
545+
}
546+
528547
enforcePacketOK(okp);
529548
ra = okp.affected;
530549
conn._serverStatus = okp.serverStatus;

0 commit comments

Comments
 (0)