Module: LapisLazuli::WorldModule::Logging
- Includes:
- Config
- Included in:
- LapisLazuli, Browser, Proxy
- Defined in:
- lib/lapis_lazuli/world/logging.rb
Overview
Module for easy logging
Manages the following:
@log - TeeLogger instances
Instance Method Summary collapse
-
#log(msg = nil) ⇒ Object
Log “singleton”.
Methods included from Config
#add_config_from_file, #config, #current_env, #env, #env_or_config, #get_config_from_file, #has_config?, #has_env?, #has_env_or_config?, #init, #load_config, #metadata, #var_from_env
Methods included from Config::ClassMethods
#add_config, #config_file, #config_file=, #config_files
Instance Method Details
#log(msg = nil) ⇒ Object
Log “singleton”
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lapis_lazuli/world/logging.rb', line 27 def log(msg = nil) super(msg) if msg return Runtime.instance.set_if(self, :logger) do # Make log directory dir = env_or_config('log_dir') begin Dir.mkdir dir rescue SystemCallError => ex # Swallow this error; it occurs (amongst other situations) when the # directory exists. Checking for an existing directory beforehand is # not concurrency safe. end # Start the logger with the config filename log_file = "#{dir}#{File::SEPARATOR}#{File.basename(Config.config_files[0], ".*")}.log" # Or a filename from the environment if has_env_or_config?("log_file") log_file = env_or_config("log_file") end l = TeeLogger::TeeLogger.new(log_file) l.level = env_or_config("log_level") l end end |