logging - how to make a generic path for a log file in Ruby -


here creating logs folder under current path of directory using dir::pwd. want change pick directory path config files run in other machines.

date_directory= "#{dir::pwd}/logs/#{datehelper.getdirectoryyearstamp}/#{datehelper.getdirectorymonthstamp}/#{datehelper.getdirectorydatestamp}/"           fileutils.mkdir_p(date_directory) unless dir.exists?(date_directory) 

i tired giving absolute path , works. how make directory passing relative path?

you allready using relative path, is generic solution, subfolder of current folder relative position. code published working ? inside question mention config files, want ? kind of file ? yaml, ini or of simple text file ? if simple textfile can with

path = file.read("#{file.dirname(__file__)}/path.txt") 

edit: based on comment, following snippets wil create logfile day in /some/x/y/z folder.

require 'logger'  $log = logger.new("/some/x/y/z/logs.txt", 'daily' ) $log.info "teststring" 

gives in file "c:\some\x\y\z\logs.txt"

# logfile created on 2013-04-05 13:17:27 +0200 logger.rb/31641 i, [2013-04-05t13:20:19.811837 #3300]  info -- : teststring 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -