Reputation: 16918
Is there a way to silence/disable mysql output in the development.log?
For example this stuff:
SQL (0.4ms) INSERT INTO `billing_infos` (`billing_method`, `city`, `company_id`, `country`, `created_at`, `email`, `fax_number`, `phone_number`, `postal_code`, `province`, `street`, `updated_at`) VALUES (NULL, 'Montreal', NULL, 'Canada', '2011-10-26 20:53:45', NULL, NULL, '(123) 456 7890', 'H1H1H1', 'QC', '1111 Temp', '2011-10-26 20:53:45')
(0.3ms) COMMIT
(0.2ms) BEGIN
(0.1ms) COMMIT
(0.1ms) BEGIN
(0.4ms) SELECT 1 FROM `sectors` WHERE (`sectors`.`name` = BINARY 'General 25' AND `sectors`.`id` != 1) LIMIT 1
Upvotes: 1
Views: 1887
Reputation: 35149
If you want to suppress almost all log output, @Shirjeel's approach will work, though I find it a bit heavy handed.
If you prefer to suppress output for a single ActiveRecord class, and only within a specific block, you can use silence
:
BillingInfo.silence do
BillingInfo.create(:city => "Montreal")
BillingInfo.create(:city => "Ottawa")
... etc
end
If you want to suppress output for all ActiveRecord subclasses, you can do
ActiveRecord::Base.silence do
... manipulate database quietly here...
end
I use this when I'm importing a large block of records or generating large test cases.
Upvotes: 4
Reputation: 154
Add following line to your config/environments/development.rb file
config.log_level = :info
Upvotes: 1