title: Set class variable from module
body: <p>I want to have separate logs for my app. I created the following module:</p>
  
  <pre><code>module MyApp
    module MyLog
      def self.included(base)
        base.extend(ClassMethods)
      end
  
      module ClassMethods
        def logger
          @@logger ||= Logger.new("#{Rails.root}/log/#{self.name.underscore}.log")
        end
      end
    end
  end
  </code></pre>
  
  <p>Then, in any of my models, I can add:</p>
  
  <pre><code>include MyApp::MyLog
  </code></pre>
  
  <p>and use it as (log file will appear in <code>.../log/cat.log</code>):</p>
  
  <pre><code>Cat.logger.info 'test'
  </code></pre>
  
  <p>I tried to use this method <code>included</code> on <code>Cat</code> and <code>Dog</code> models, and I have this result:</p>
  
  <pre><code>Cat.new.logger
  # =&gt; #&lt;Logger:0x007fe4516cf0b0 @progname=nil, ... @dev=#&lt;File:/.../log/cat.log&gt;, ... 
  Dog.new.logger
  # =&gt; #&lt;Logger:0x007fe4516cf0b0 @progname=nil, ... @dev=#&lt;File:/.../log/cat.log&gt;, ... (the same)
  </code></pre>
  
  <p>If I try to use my logger for <code>Dog</code> model first, I will have a log file with the name <code>dog</code> (<code>/dog.log</code>).</p>
  
  <p>How can I set class variable <code>@@logger</code> from a module for each class with the correct initialized logger?</p>