Powered by SmartDoc

Debugging

Running on command-line

Applications run on offline-mode when you run them on command-line. Input form data for the applications in ?name=value? format and push Ctrl-D to run.

[localhost:/cgi-bin/Examples] user% ./Examples.cgi
(offline mode: enter name=value pairs on standard input)
# Ctrl-D
Content-Type: text/html

<html>
<head>
<title>Examples</title>
</head>
<frameset cols="200,*">
    <frame name="Index" src="?element_id=IndexPage">
    <frame name="Contents" src="?element_id=IntroductionPage">
    <noframes>
        <body>
            Use other browser.
        </body>
    </noframes>
</frameset>

Checking attributes of elements

If you set true to check_attributesattribute of CKApplication, CGIKit checks attributes of elements on runtime. It raises errors if nonexistent attributes are setted or required attributes aren?t setted.

Logging

CKLog is a simple logging class with 5 debug levels, It writes log messages higher than setted level. The debug level is ?DEBUG < INFO < WARN < ERROR < FATAL?.

Logging methods
Method Description
debug(message) Write messageon DEBUG level.
info(message) Write messageon INFO level.
warn(message) Write messageon WARN level.
error(message) Write messageon ERROR level.
fatal(message) Write messageon FATAL level.

Options

Logging options are the following. Use log_optionsattribute of CKApplication to initialize CKLog objects instead of setting each options to do directly.

Options
Option Description
level Debug level.
name Program name.
out Output. By default is standard error.
file File name to output logs. Set this or outoption.
max_file_size Max file size (this enables if you set file to output). If size of the file is over this size, FileSizeErroris raised.
options = {?level?         => CKLog::DEBUG,
           ?name?          => ?CGIKit Application?,
           ?file?          => ?log.txt?,
           ?max_file_size? => 1000000}

app = CKApplication.new
app.log_options = options
app.run
class MainPage < CKComponent
  def logging
    log = CKLog.new(application.log_options)
    log.debug ?log message?
  end
end