不显示 Assets Pipeline 的日志

本文介绍了一种在Rails应用中静默处理assets请求日志的方法,通过修改配置文件实现开发环境中对静态资源请求的日志级别调整,有助于提高开发效率并减少不必要的日志输出。

创建文件 config/initializers/quiet_assets.rb

 

写入代码

if Rails.env.development?
  Rails.application.assets.logger = Logger.new('/dev/null')
  Rails::Rack::Logger.class_eval do
    def call_with_quiet_assets(env)
      previous_level = Rails.logger.level
      Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
      call_without_quiet_assets(env)
    ensure
      Rails.logger.level = previous_level
    end
    alias_method_chain :call, :quiet_assets
  end
end

 

Started by user administrator Obtained uat_tc/frontend/Jenkinsfile from git http://47.100.45.4:8060/pipeline/dbm-ci.git [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Checkout SCM) [Pipeline] checkout The recommended git tool is: NONE using credential dbm-deploy > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/.git # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url http://47.100.45.4:8060/pipeline/dbm-ci.git # timeout=10 Fetching upstream changes from http://47.100.45.4:8060/pipeline/dbm-ci.git > git --version # timeout=10 > git --version # 'git version 2.39.5' using GIT_ASKPASS to set credentials > git fetch --tags --force --progress -- http://47.100.45.4:8060/pipeline/dbm-ci.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 Checking out Revision 39c6e6fb53f67b249d725128e27fe95d10d8c634 (refs/remotes/origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f 39c6e6fb53f67b249d725128e27fe95d10d8c634 # timeout=10 Commit message: "前端部署脚本修改" > git rev-list --no-walk 39c6e6fb53f67b249d725128e27fe95d10d8c634 # timeout=10 [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Tool Install) [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Checkout) [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] withEnv [Pipeline] { [Pipeline] git The recommended git tool is: NONE using credential dbm-deploy > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/.git # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url http://47.100.45.4:8060/ifourthwall-frontend/dbm-provider-miniapp-ext.git # timeout=10 Fetching upstream changes from http://47.100.45.4:8060/ifourthwall-frontend/dbm-provider-miniapp-ext.git > git --version # timeout=10 > git --version # 'git version 2.39.5' using GIT_ASKPASS to set credentials > git fetch --tags --force --progress -- http://47.100.45.4:8060/ifourthwall-frontend/dbm-provider-miniapp-ext.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse refs/remotes/origin/uat^{commit} # timeout=10 Checking out Revision d96cc2d276749987f956838156865e2c99d68c70 (refs/remotes/origin/uat) > git config core.sparsecheckout # timeout=10 > git checkout -f d96cc2d276749987f956838156865e2c99d68c70 # timeout=10 > git branch -a -v --no-abbrev # timeout=10 > git checkout -b uat d96cc2d276749987f956838156865e2c99d68c70 # timeout=10 Commit message: "合并分支 'test' 到 'uat'" First time build. Skipping changelog. [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Build) [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] withEnv [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] sh + rm -rf node_modules + node -v v18.20.3 + git remote set-url origin https://github.com/evrone/postcss-px-to-viewport.git + npm install --registry=https://registry.npmmirror.com npm warn deprecated yaeti@0.0.6: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. added 346 packages in 2s 77 packages are looking for funding run `npm fund` for details + npm run build:uat > cssccrane@0.0.0 build:uat > vite build --mode uat postcss-px-to-viewport: postcss.plugin was deprecated. Migration guide: https://evilmartians.com/chronicles/postcss-8-plugin-migration vite v5.4.20 building for uat... transforming... DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0. More info and automated migrator: https://sass-lang.com/d/import ╷ 1 │ @use "@/assets/css/constant.scss" as *;@import "./base.scss"; │ ^^^^^^^^^^^^^ ╵ src/assets/css/index.scss 1:48 root stylesheet DEPRECATION WARNING [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0. More info and automated migrator: https://sass-lang.com/d/import ╷ 2 │ @import "./constant.scss"; │ ^^^^^^^^^^^^^^^^^ ╵ src/assets/css/index.scss 2:9 root stylesheet DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. More info: https://sass-lang.com/d/legacy-js-api ✓ 430 modules transformed. Generated an empty chunk: "@antfu". Generated an empty chunk: "vue". Generated an empty chunk: "vue-demi". x Build failed in 1.87s error during build: [vite:esbuild-transpile] Transform failed with 2 errors: assets/vant-!~{00b}~.js:2878:6: ERROR: The symbol "bem" has already been declared assets/vant-!~{00b}~.js:5104:6: ERROR: The symbol "bem" has already been declared  The symbol "bem" has already been declared 2876| const Tabs = withInstall(stdin_default$f); 2877| 2878| const [name$c, bem] = createNamespace("picker-group"); | ^ 2879| const PICKER_GROUP_KEY = Symbol(name$c); 2880| extend({ The symbol "bem" has already been declared 5102| const Notify = withInstall(stdin_default$2); 5103| 5104| const [name$1, bem, t] = createNamespace("search"); | ^ 5105| const searchProps = extend({}, fieldSharedProps, { 5106| label: String,  at failureErrorWithLog (/var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/node_modules/esbuild/lib/main.js:1472:15) at /var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/node_modules/esbuild/lib/main.js:755:50 at responseCallbacks.<computed> (/var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/node_modules/esbuild/lib/main.js:622:9) at handleIncomingPacket (/var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/node_modules/esbuild/lib/main.js:677:12) at Socket.readFromStdout (/var/jenkins_home/workspace/prd-frontend-dbm-provider-miniapp-ext/node_modules/esbuild/lib/main.js:600:7) at Socket.emit (node:events:517:28) at addChunk (node:internal/streams/readable:368:12) at readableAddChunk (node:internal/streams/readable:341:9) at Readable.push (node:internal/streams/readable:278:10) at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Deploy) Stage "Deploy" skipped due to earlier failure(s) [Pipeline] getContext [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE
09-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值