<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nishikawa1031</title>
    <description>The latest articles on DEV Community by nishikawa1031 (@nishikawa1031).</description>
    <link>https://dev.to/nishikawa1031</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1165900%2F643c63de-4492-4310-b84b-2867fc19fe50.jpeg</url>
      <title>DEV Community: nishikawa1031</title>
      <link>https://dev.to/nishikawa1031</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nishikawa1031"/>
    <language>en</language>
    <item>
      <title>A new gem that eliminates the hassle of launching the Rails app every time just to check the logs.</title>
      <dc:creator>nishikawa1031</dc:creator>
      <pubDate>Wed, 20 Sep 2023 10:01:53 +0000</pubDate>
      <link>https://dev.to/nishikawa1031/a-new-gem-that-eliminates-the-hassle-of-launching-the-rails-app-every-time-just-to-check-the-logs-1pp8</link>
      <guid>https://dev.to/nishikawa1031/a-new-gem-that-eliminates-the-hassle-of-launching-the-rails-app-every-time-just-to-check-the-logs-1pp8</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;During Rails development, I found that the wait time to start the Rails server was surprisingly stressful. On the other hand, the logs output to &lt;code&gt;development.log&lt;/code&gt; were often overwhelming...&lt;/p&gt;

&lt;p&gt;So, I created a gem that divides and outputs the logs by each controller's action in separate folders, allowing for easier management of logs during each request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rubygems.org/gems/custom_log_space"&gt;custom_log_space | RubyGems.org | Community Gem Hosting Service&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Add &lt;code&gt;gem 'custom_log_space'&lt;/code&gt; to your Gemfile as shown below and run &lt;code&gt;bundle install&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;group :development do
&lt;/span&gt;  + gem 'custom_log_space'
&lt;span class="p"&gt;end
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Launch your Rails app locally. When you access a page, logs will be generated in the &lt;code&gt;log/custom_log_space&lt;/code&gt; directory, following the naming convention below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;log/custom_log_space/#{controller_name}/#{action_name}/#{date}/#{time}.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user log % tree
.
├── custom_log_space
│   └── articles_controller
│       ├── index
│       │   ├── 2023-09-19
│       │   │   ├── 09:13.log
│       │   │   └── 20:00.log
│       │   └── saved
│       └── show
│           ├── 2023-09-18
│           │   ├── 21:29.log
│           │   └── 22:02.log
│           ├── 2023-09-19
│           │   └── 20:00.log
│           └── saved
└── development.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Log Retention Policy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The maximum number of &lt;code&gt;#{date}&lt;/code&gt; folders retained is two, and for &lt;code&gt;#{time}.log&lt;/code&gt;, up to 10 files. Once these limits are exceeded, older files will be deleted sequentially.&lt;/li&gt;
&lt;li&gt;Please move important logs to the saved directory.
&lt;code&gt;log/custom_log_space/#{controller_name}/#{action_name}/saved/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If a single request triggers multiple controller actions, logs will be organized into separate folders for each action. Therefore, caution is needed when tracing the logs.&lt;/li&gt;
&lt;li&gt;However, even after introducing this gem, the output to the existing &lt;code&gt;development.log&lt;/code&gt; remains unchanged. You can continue to refer to it as needed.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>rails</category>
      <category>gem</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
