Jump to content

  •  

Photo

Logging messages to a Log table


  • Please log in to reply
4 replies to this topic

#1 xochi  veteran

xochi
  • Members
  • 679 posts
  • FM Application:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Expert
  • Membership:TechNet
  • Time Online: 1d 11h 45m 47s

Posted 08 March 2012 - 08:47 AM

In all of my fm databases, I find that having a logging table is very useful. I've created some scripts that do this :

Log($msg, $severity, $user...) // adds a timestamped log message to the log table with given severity
e.g.

PerformScript("$msg=\"Bad error occurred in XXXX\" ; $severity=\"Error\" ; $user=\"" & Get(CurrentUser)& "\";")

However, the actual script is not very fast or efficient, as it basically does this:

* create a new window showing the log table (or show it if it's already open)
* create a new record in the log table
* fill in the fields
* commit
* close or hide the log window

The reason that I use a separate window for the log table, rather than simply using "go to layout "Log" ; ... ; Go to layout (original layout)" is that I've found that switching layouts can cause some issues (tab panel tab is lost, portals lose their scroll position, etc.) Also, this means I can call the script from anywhere, even if the current table doesn't have a relationship to the log table.

Question: is there a better way? I was wondering if there was some clever way to get the same result without switching windows or layouts?
  • 0

#2 dansmith65  Independent Contractor

dansmith65
  • Members
  • 853 posts
  • LocationB.C. Canada
  • Certification:8, 11
  • Membership:TechNet
  • Time Online: 14d 19h 41m 3s

Posted 08 March 2012 - 10:09 AM

You could use an SQL plug-in.
  • 0

#3 Vaughan  Mostly Harmless

Vaughan
  • Moderators
  • 10,294 posts
  • LocationSydney, Australia
  • FM Application:13 Advance
  • FMGo:iPhone / iPod Touch, iPad
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:8, 9, 10, 11
  • Membership:TechNet
  • Time Online: 4d 9h 48s

Posted 08 March 2012 - 03:11 PM

Try using a "magic key" method to create related records. This works through a global field and does not require changing layouts.

http://www.filemakerhacks.com/?p=2364
  • 0
Vaughan Bromfield
Sydney, Australia

Please post questions to the Forum, not directly to me. Back-up your files before making changes!

Whenever I hear the term "popular culture" I reach for my Iridium Q-36 Space Modulator.

#4 xochi  veteran

xochi
  • Members
  • 679 posts
  • FM Application:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Expert
  • Membership:TechNet
  • Time Online: 1d 11h 45m 47s

Posted 09 March 2012 - 10:38 AM

Try using a "magic key" method to create related records. This works through a global field and does not require changing layouts.

http://www.filemakerhacks.com/?p=2364


Very cool : reading this, I had some questions.

* Can this be used from any layout? Or does it need to be run from a layout that has the g_magic_key relationship? If so thats a little limiting compared to my scripted version (which has the advantage that it can be called from anywhere).

* Is this multi-user safe? It should be since it uses globals.

* Is this single-user recursive safe? I'm guessing it's not, since the global key value would be the same for a single user. (The scenario I'm imagining is an error that happens in the logging code itself, so that the logging code tries to log an error in the middle of logging a message. Probably not a big problem.)
  • 0

#5 dansmith65  Independent Contractor

dansmith65
  • Members
  • 853 posts
  • LocationB.C. Canada
  • Certification:8, 11
  • Membership:TechNet
  • Time Online: 14d 19h 41m 3s

Posted 09 March 2012 - 09:24 PM

the logging code tries to log an error in the middle of logging a message

Be carefull when designing this; specifically look out for creating an infinite loop in your script.
  • 0




FMForum Advertisers