TAILIEUCHUNG - Rails for Java Developers phần 6

Ruby là một ngôn ngữ hướng đối tượng: mỗi bit dữ liệu đều là một đối tượng (object), bao gồm các kiểu dữ liệu mà đối với các ngôn ngữ khác, chúng là kiểu cơ bản (primitive) như integer. Mỗi hàm (function) là một phương thức (method). Tên biến (variables) chính là tham khảo (references) đến các đối tượng, bản thân nó không phải là đối tượng. | Logging Debugging and Benchmarking 157 of ActiveRecord and Actioncontroller provide a logger method with a preconfigured logger. The logger has named methods for different log levels just as in Java. To log an INFO message do the following Download code rails_xt app controllers def destroy Entering destroy method That is easy enough but you will not see that kind of logging in a Rails application often. Rails includes a ton of information in its own logging statements and this information is often sufficient enough that you do not need to make any additional calls to the logger. Here is the log output from creating a new person Download code people snippets Processing PeopleController create for at 2006-10-30 11 58 17 POST Session ID 08ecf4526b2d1b38406396d58a538e02 Parameters commit Create action create controller people person first_name Jean last_name Dough Person Columns SHOW FiElDS from people SQL BEGIN SQL INSERT INTO people first_name last_name VALUES Jean Dough SQL COMMIT Redirected to http localhost 3000 people list Completed in 2 reqs sec Db 97 302 Found http localhost people create Rails logging gives you the following information for every request The URL host time and HTTP verb line 1 The user s session id line 2 The request parameters including controller and action line 3 The SQL statements executed with timing information line 5 The templates rendered or redirects issued line 10 The HTTP response code and total time to handle the request line 11 By default Rails logging emits ANSI control sequences which colorize the log lines for supported terminals. For all other viewers these control sequences are just gibberish so we usually turn them off in Download code people config ActiveRecord false Logging Debugging and Benchmarking 158 Rails log level names are almost the same as the log4j .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.