Class: Msf::Logging
- Inherits:
-
Object
- Object
- Msf::Logging
- Defined in:
- lib/msf/base/logging.rb
Overview
This module provides an initialization interface for logging.
Constant Summary collapse
- @@initialized =
Is logging initialized
false
- @@session_logging =
Is session logging enabled
false
Class Method Summary collapse
-
.disable_log_source(src) ⇒ Boolean
Stops logging for a given log source.
-
.enable_log_source(src, level = 0) ⇒ void
Enables a log source of name src.
-
.enable_session_logging(tf) ⇒ void
Sets whether or not session logging is to be enabled.
-
.init(log_sink_name = nil) ⇒ void
Initialize logging.
-
.session_logging_enabled? ⇒ Boolean
Returns whether or not session logging is enabled.
-
.start_session_log(session) ⇒ void
Starts logging for a given session.
-
.stop_session_log(session) ⇒ Boolean
Stops logging for a given session.
Class Method Details
.disable_log_source(src) ⇒ Boolean
Stops logging for a given log source.
60 61 62 |
# File 'lib/msf/base/logging.rb', line 60 def self.disable_log_source(src) deregister_log_source(src) end |
.enable_log_source(src, level = 0) ⇒ void
This method returns an undefined value.
Enables a log source of name src. Creates the .log file in the configured directory if logging is not already enabled for this source.
47 48 49 50 51 52 53 54 |
# File 'lib/msf/base/logging.rb', line 47 def self.enable_log_source(src, level = 0) if (log_source_registered?(src) == false) f = Rex::Logging::Sinks::Flatfile.new( Msf::Config.log_directory + File::SEPARATOR + "#{src}.log") register_log_source(src, f, level) end end |
.enable_session_logging(tf) ⇒ void
This method returns an undefined value.
Sets whether or not session logging is to be enabled.
68 69 70 |
# File 'lib/msf/base/logging.rb', line 68 def self.enable_session_logging(tf) @@session_logging = tf end |
.init(log_sink_name = nil) ⇒ void
This method returns an undefined value.
Initialize logging.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/msf/base/logging.rb', line 19 def self.init(log_sink_name = nil) if (! @@initialized) @@initialized = true log_sink ||= Rex::Logging::LogSinkFactory.new( log_sink_name, Msf::Config.log_directory + File::SEPARATOR + "framework.log" ) # Register each known log source [ Rex::LogSource, Rex::Socket::LogSource, Msf::LogSource, 'base', ].each { |src| register_log_source(src, log_sink) } end end |
.session_logging_enabled? ⇒ Boolean
Returns whether or not session logging is enabled.
75 76 77 |
# File 'lib/msf/base/logging.rb', line 75 def self.session_logging_enabled? @@session_logging || false end |
.start_session_log(session) ⇒ void
This method returns an undefined value.
Starts logging for a given session.
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/msf/base/logging.rb', line 83 def self.start_session_log(session) if (log_source_registered?(session.log_source) == false) f = Rex::Logging::Sinks::TimestampColorlessFlatfile.new( Msf::Config.session_log_directory + File::SEPARATOR + "#{session.log_file_name}.log") register_log_source(session.log_source, f) rlog("\n[*] Logging started: #{Time.now}\n\n", session.log_source) end end |
.stop_session_log(session) ⇒ Boolean
Stops logging for a given session.
98 99 100 101 102 |
# File 'lib/msf/base/logging.rb', line 98 def self.stop_session_log(session) rlog("\n[*] Logging stopped: #{Time.now}\n\n", session.log_source) deregister_log_source(session.log_source) end |