Skip to content

Commit

Permalink
sql logger + test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Feb 28, 2018
1 parent 8fef47e commit 9aadcca
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Qutheory, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<p align="center">
<img src="https://cloud.githubusercontent.com/assets/1342803/24657467/a61b5c12-1946-11e7-9b98-b916bbc5fddd.png" width="320" alt="MySQL Driver">
<img src="https://user-images.githubusercontent.com/1342803/36770929-446759fc-1c1b-11e8-9a66-5594a66f15b9.png" height="64" alt="Fluent MySQL">
<br>
<br>
<a href="https://docs.vapor.codes/2.0/mysql/package/">
<img src="http://img.shields.io/badge/read_the-docs-92A8D1.svg" alt="Documentation">
<a href="https://docs.vapor.codes/3.0/">
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
</a>
<a href="http://vapor.team">
<img src="http://vapor.team/badge.svg" alt="Slack Team">
</a>
<a href="LICENSE">
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
</a>
<a href="https://circleci.com/gh/vapor/mysql-driver">
<img src="https://circleci.com/gh/vapor/mysql-driver.svg?style=shield" alt="Continuous Integration">
<a href="https://circleci.com/gh/vapor/fluent-mysql">
<img src="https://circleci.com/gh/vapor/fluent-mysql.svg?style=shield" alt="Continuous Integration">
</a>
<a href="https://swift.org">
<img src="http://img.shields.io/badge/swift-3.1-brightgreen.svg" alt="Swift 3.1">
<img src="http://img.shields.io/badge/swift-4.1-brightgreen.svg" alt="Swift 4.1">
</a>
</p>
4 changes: 1 addition & 3 deletions Sources/FluentMySQL/MySQLDatabase+Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ extension MySQLDatabase: QuerySupporting {

/// Create a MySQL query string
let sqlString = MySQLSerializer().serialize(data: dataQuery)

/// FIXME
// _ = self.logger?.log(query: sqlString)
_logger?.log(query: sqlString)

if query.data == nil && binds.count == 0 {
do {
Expand Down
1 change: 1 addition & 0 deletions Sources/FluentMySQL/MySQLDatabase+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extension MySQLDatabase: SchemaSupporting {

let serializer = MySQLSerializer()
let sqlString = serializer.serialize(schema: schemaQuery)
_logger?.log(query: sqlString)

return connection.administrativeQuery(sqlString)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/FluentMySQL/MySQLDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import MySQL
import Service
import SQL

/// If set, query logs will be sent to the supplied logger.
internal var _logger: MySQLLogger?

/// A reference to a MySQL database
public final class MySQLDatabase: Service {
/// The hostname to which connections will be connected
Expand All @@ -23,9 +26,6 @@ public final class MySQLDatabase: Service {
/// The database to select
let database: String

/// If set, query logs will be sent to the supplied logger.
public var logger: MySQLLogger?

public init(hostname: String, port: UInt16 = 3306, user: String, password: String?, database: String) {
self.hostname = hostname
self.port = port
Expand Down Expand Up @@ -69,7 +69,7 @@ extension MySQLDatabase: Database, LogSupporting {

/// See SupportsLogging.enableLogging
public func enableLogging(using logger: DatabaseLogger) {
self.logger = logger
_logger = logger
}
}

Expand Down
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- checkout
- run: swift build
- run: swift test
- run: swift build -c release

workflows:
version: 2
Expand Down

0 comments on commit 9aadcca

Please sign in to comment.