I really like the idea of changing the logFunc type if everyone is OK with that. To further refine it, the trait could define three defs:
def getStatements : List[(String,Long)] def getMetaCommands : List[(String,Long)] def getAll : List[(String,Long)] getAll would return the union of the first two, in proper sequential order. I could further refine this by making use of case classes instead of (String,Long): sealed abstract class DBLogEntry case class LoggedStatement(statement : String, duration : Long) extends DBLogEntry case class LoggedMetaCommand(statement : String, duration : Long) extends DBLogEntry I don't know enough detail on JDBC to know whether or not meta commands require round-trips to the DB or if the spec requires that they're all local, but it seems like we should just time everything. Thoughts? On Sun, Aug 16, 2009 at 8:31 AM, marius d. <[email protected]> wrote: > > > > On Aug 16, 5:18 pm, Derek Chen-Becker <[email protected]> wrote: > > Yeah, I was actually thinking about that same angle last night. Perhaps I > > could provide some control var on DB to enable detailed or basic logging? > > Yeah ... or maybe for the logFunc to not pass just a query string but > an object (abstracted by a trait) and let the user extract from there > whatever is needed. Just the plain query and/or other stuff. Yes this > would mean a breaking change but I think a good one. > > > I > > think that it would be very useful in some cases, for example, to know > that > > underlying code is setting max rows or max fetch size, but I agree that > most > > people will probably just want basic statements logged. Also, with a > > prepared statement someone *could* execute multiple queries in one go, so > I > > can't get rid of the list of stuff. > > Totally agree, but please see my notes above. > > > Another approach would be to give the > > logFuncs List to the Logging classes and then they could decide whether > to > > log (and time) each execution individually or all at once (if someone > sets > > batch mode, for example). What do you think? > > Based on the above I'd probably opt in for a trait rather then the > List. > > Perhaps : > > trait LogStatement { > > def getStatement: (String, Long) // returns the statement and the > tiem spent > > def getDetailedInfo: List[String] // /returns your list > > } > > > ... or you may be thinking of a better abstraction. > > And logFuncs would become: > > logFuncs: List[(LogStatement) => Any] = Nil > > > Br's, > Marius > > > > > Derek > > > > On Sun, Aug 16, 2009 at 8:09 AM, marius d. <[email protected]> > wrote: > > > > > Derek, > > > > > I was looking to your code, GOOD stuff ! One thing though.The > > > LoggedStatement.toString would return a List of log entries and not a > > > query but the user's Log function expects a query and the time spent > > > on that query so there is a little miss match between when user's > > > function expects and what we're feeding to it. Also you are creating > > > strings like: > > > > > "Exec query \"%s\" : rs = %s".format(sql, rs)" > > > > > ...which may be perfect. But I wonder if user's won't expect just the > > > query/update and nothing else and they will do their own logging and > > > formatting. > > > > > Br's, > > > Marius > > > > > On Aug 16, 3:07 am, Derek Chen-Becker <[email protected]> wrote: > > > > I only fixed the groupId because maven was giving me a warning that > it > > > had > > > > changed. I can bump the versions to 0.9.5 this week and if that > builds > > > fine > > > > I'll check it in. > > > > > > On Sat, Aug 15, 2009 at 3:22 PM, Bill Venners <[email protected]> > wrote: > > > > > Hi Derek, > > > > > > > I noticed you checked in a change to Lift that updated the Maven > > > ScalaTest > > > > > ref. However the ref is to version 0.9.4, whereas the current > version > > > is > > > > > 0.9.5. > > > > > > > Thanks. > > > > > > > Bill---- > > > > > Bill Venners > > > > > Artima, Inc. > > > > >http://www.artima.com > > > > > > > On Aug 15, 2009, at 7:02 AM, Derek Chen-Becker < > [email protected]> > > > > > wrote: > > > > > > > OK, a preliminary version of log wrappers is checked in on > > > > > wip-dcb-sql-log-wrappers. I'll merge it on Tuesday if no one sees > any > > > > > problems with it. > > > > > > > Derek > > > > > > > On Tue, Aug 11, 2009 at 11:08 AM, Derek Chen-Becker << > > > [email protected]> > > > > > [email protected]> wrote: > > > > > > >> Will do. > > > > > > >> On Tue, Aug 11, 2009 at 2:33 AM, marius d. < < > [email protected] > > > > > > >> [email protected]> wrote: > > > > > > >>> Please do so. If you need any help for some reason (time > availability > > > > >>> etc.) please let me know. As a note probably the wrappers should > be > > > > >>> only only when there is at least one log function registered. > > > > > > >>> Br's, > > > > >>> Marius > > > > > > >>> On Aug 6, 11:48 pm, Derek Chen-Becker <[email protected]> > wrote: > > > > >>> > If there's a consensus that we want our own JDBC wrappers I'll > go > > > ahead > > > > >>> and > > > > >>> > write them. > > > > > > >>> > Derek > > > > > > >>> > On Thu, Aug 6, 2009 at 1:19 PM, marius d. < > [email protected] > > > > > > >>> wrote: > > > > > > >>> > > Probably building our own wrappers would be more lightweight > then > > > > >>> 3-rd > > > > >>> > > party. Jus' guessing > > > > > > >>> > > Br's, > > > > >>> > > Marius > > > > > > >>> > > On Aug 6, 9:58 pm, Derek Chen-Becker <[email protected]> > > > wrote: > > > > >>> > > > Well, I started looking at it and determined that the only > way > > > for > > > > >>> us to > > > > >>> > > > truly log the queries would be to essentially make our own > > > wrappers > > > > >>> over > > > > >>> > > > Statement and PreparedStatement. There are projects > (log4jdbc, > > > > >>> notably) > > > > >>> > > that > > > > >>> > > > already do this, and in a transparent manner. I'm not sure > that > > > > >>> adding a > > > > >>> > > > whole bunch of SQL logging directly to Lift is better than > > > > >>> leveraging > > > > >>> > > some > > > > >>> > > > existing libraries to do it. > > > > > > >>> > > > Derek > > > > > > >>> > > > On Thu, Aug 6, 2009 at 11:03 AM, marius d. < > > > > >>> [email protected]> > > > > >>> > > wrote: > > > > > > >>> > > > > Yeah we're aware of that. That is based on toString > > > application > > > > >>> which > > > > >>> > > > > is JDBC driver dependent. I think Derek started some work > on > > > this > > > > >>> to > > > > >>> > > > > correct this behavior. Derek ? > > > > > > >>> > > > > Br's, > > > > >>> > > > > Marius > > > > > > >>> > > > > On Aug 6, 8:01 pm, jon <[email protected]> wrote: > > > > >>> > > > > > Hi, > > > > > > >>> > > > > > I have the following in boot: > > > > >>> > > > > > DB.addLogFunc((query, len) => Log.info("The query: > > > "+query+" > > > > >>> took > > > > >>> > > > > > "+len+" milliseconds")) > > > > > > >>> > > > > > I was expecting the query parameter to be sql, but it's > > > > >>> actually some > > > > >>> > > > > > sort of guid > > > > > > >>> > > > > > "INFO - The query: 6839c016-0122-f09a-9c96-0000003844e8 > > > took 5 > > > > >>> > > > > > milliseconds" > > > > > > >>> > > > > > Any ideas? > > > > >>> > > > > > I'm running with derby. > > > > > > >>> > > > > > Thanks, > > > > > > >>> > > > > > Jon > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
