Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[review] DataMigrationOperator のログの出力に対応 #38

Merged
merged 2 commits into from
Dec 15, 2022

Conversation

kei-p
Copy link
Member

@kei-p kei-p commented Dec 15, 2022

No description provided.

@@ -13,6 +13,7 @@ def self.execute(title, options = {}, &block)
def initialize(title, options = {})
@title = title
@options = options
@logger = @options[:logger] || Logger.new(Rails.root.join("log/data_migration_#{title.gsub(/[[:space:]]/, '')}.log"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tilteそのままファイル名に使うとescape周りが面倒そうだから(↑だと怖そう)、titleそのまま使う必要性が低いのであればdata_migration_実行日時.logとかのほうが安心で良さそうだなと思いました。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あとこれだとログを無効化するのが面倒なので、↓みたいなほうが良さそう。(logger: nilで済むように)
他のオプション初期化コードとも揃うし。

Suggested change
@logger = @options[:logger] || Logger.new(Rails.root.join("log/data_migration_#{title.gsub(/[[:space:]]/, '')}.log"))
@logger = @options.fetch(:logger) { Logger.new(Rails.root.join("log/data_migration_#{title.gsub(/[[:space:]]/, '')}.log")) }

@aki77 aki77 merged commit 48d6276 into master Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants