`
CaiDeHen
  • 浏览: 96815 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

#86 Logging Variables

阅读更多
Have you ever wanted to easily log all variables? Now you can by using some advanced Ruby concepts as shown in this episode.
# models/product.rb
logger.debug_variables(binding)

# config/initializers/logger_additions.rb
logger = ActiveRecord::Base.logger
def logger.debug_variables(bind)
  vars = eval('local_variables + instance_variables', bind)
  vars.each do |var|
    debug  "#{var} = #{eval(var, bind).inspect}"
  end
end
分享到:
评论

相关推荐

    工具:改进Wa的工具的舞台

    工具模具改进的舞台。 请参阅。 从Wagtail社区中查看以获取更多令...touch .env# Configure Wagtail user session ID to use.# Get this value by logging into the Wagtail admin of your site, then# use the develop

    精通.SQL.Server.2012.集成服务.Francis.Rodrigues,.Michael.Coles,.David.Dye,.文字版

    - **Logging** 和 **Auditing** 是记录SSIS包执行过程中的活动和状态的关键技术。 - 本章将讨论如何配置日志记录和审计策略,以满足合规性和跟踪需求。 ### 14. Heterogeneous Sources and Destinations #### 关键...

    CodeSite.v.5.2.1.XE10

    A key element to CodeSite's effectiveness is that unlike message boxes and inspecting variables on breakpoints, CodeSite messages are not transient. The resulting log of messages provides valuable ...

    traceback_with_variables:将变量添加到python追溯。简单,轻巧,可控。通过为堆栈跟踪中的每一帧记录或漂亮地打印彩色变量上下文来调试异常原因,以显示每个值。错误后将本地环境转储到控制台,文件和记录器。可在Jupyter和IPython中使用。使用pip或conda安装

    Python回溯(错误消息)打印变量 使用非常简单,但是在需要时具有多功能性。...conda install -c conda-forge traceback-with-variables :rocket:快速开始 使用不进行代码编辑的情况下, : traceba

    ns-3-manual_r3.21

    #### 二、随机变量(Random Variables) ##### 2.1 快速概览 NS3中的随机变量是模拟网络行为中非常重要的组成部分。这部分内容提供了对随机变量的快速介绍,包括它们的作用和使用方法。这对于初次接触NS3的用户来说...

    Android代码-lombok

    Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more. See LICENSE for the Project Lombok ...

    eclipse下的resin配置

    - Resin 3.x:`-Dresin.home="D:\resin-3.1.9"` 和 `-Djava.util.logging.manager=com.caucho.log.LogManagerImpl` ##### 5. 设置 Working Directory 在 `Environment` 选项卡中,设置 Working Directory 为 Resin...

    Oracle Database 10g PL-SQL Programming

    - **Error Logging**: Techniques for logging errors and debugging PL/SQL code. #### 8. Creating Procedures, Functions, and Packages Subprograms are essential for modular programming: - **Procedure ...

    Java应用日志框架TNT4J.zip

    Application state dump framework for reporting internal variables, data structures Granular conditional logging based on application tokens, patterns, that can be shared accross applications, ...

    SCJP6 Sun Certificated Programmer for Java 6 Study Guide (Exam 310-065) 英文原版

    - **Debugging Techniques**: Using debuggers and logging frameworks. - **Refactoring**: Improving code quality without changing its external behavior. - **Design Patterns**: Implementing common ...

    tomcat集成jdk和mysql+开机启动.pdf

    rem Make sure prerequisite environment variables are set if not "%JAVA_HOME%" == "" goto okHome echo The JAVA_HOME environment variable is not defined echo This environment variable is needed to ...

    CitectSCADA Cicode Reference (7.10)

    - **Logging Expression Data**: 表达式的结果可以记录下来,以便于后续分析或审计。 - **Triggering Events Using Expressions**: 表达式也可以用于触发特定事件或动作。 ### Cicode Functions #### Using Cicode...

    unix command line notes (2010)

    - **Booting & logging in(启动与登录)**: 讲述了如何启动并登录到Unix系统。 - **Rebooting from Windows to Linux on the PWF(从Windows到Linux的重启)**: 如果使用的是双系统,可以了解如何在两个操作系统间...

    PyMOTW中文文档

    - 如何使用条件变量(condition variables)来控制队列的操作。 - 如何使用队列实现线程间的同步。 #### 3. PyMOTW: StringIO and cStringIO - **描述**: `StringIO` 和 `cStringIO` 模块提供了类似于文件接口的...

    php.ini解释php.ini解释

    - **示例**:`define_syslog_variables = On` **4. 调试配置** - **示例**: ```ini debugger.host = localhost debugger.port = 7869 debugger.enabled = True ``` **5. 日志记录配置** - **示例**: ...

    ranorex使用教程

    **10.3 Logging Individual Information** 在测试过程中,用户可以记录特定的信息到日志中。这种方式对于调试测试脚本非常有用。 **10.4 Updating the Custom Report Format** 为了满足不同的需求,Ranorex 允许...

    tomcat集成jdk和mysql+开机启动实用.pdf

    rem Make sure prerequisite environment variables are set if not "%JAVA_HOME%" == "" goto okHome echo The JAVA_HOME environment variable is not defined echo This environment variable is needed to ...

    Spoon 用户指南

    • 07 Variables • 08 Transformation Settings • 09 Transformation Steps • 10 Job Settings • 11 Job Entries • 12 Graphical View • 13 Running a Transformation • 14 Logging • 15 Grids • ...

Global site tag (gtag.js) - Google Analytics