log module

binaryninja.log.Logger(session_id, logger_name)

class Logger(session_id: int, logger_name: str)[source]

Bases: object

Parameters:
  • session_id (int) –

  • logger_name (str) –

log(level: LogLevel, message: str) None[source]
Parameters:
Return type:

None

log_alert(message: str) None[source]
Parameters:

message (str) –

Return type:

None

log_debug(message: str) None[source]
Parameters:

message (str) –

Return type:

None

log_error(message: str) None[source]
Parameters:

message (str) –

Return type:

None

log_info(message: str) None[source]
Parameters:

message (str) –

Return type:

None

log_warn(message: str) None[source]
Parameters:

message (str) –

Return type:

None

close_logs()[source]

close_logs close all log files.

Return type:

None

is_output_redirected_to_log()[source]
log(level: LogLevel, text: Any, logger: str = '', session: int = 0)[source]

log writes messages to the log console for the given log level.

LogLevelName

LogLevel

Description

DebugLog

0

Logs debugging information messages to the console.

InfoLog

1

Logs general information messages to the console.

WarningLog

2

Logs message to console with Warning icon.

ErrorLog

3

Logs message to console with Error icon, focusing the error console.

AlertLog

4

Logs message to pop up window.

Parameters:
  • level (LogLevel) – Log level to use

  • text (str) – message to print

  • logger (str) –

  • session (int) –

Return type:

None

log_alert(text: Any, logger: str = '')[source]

log_alert Logs message console and to a pop up window if run through the GUI.

Parameters:
  • text (str) – message to print

  • logger (str) –

Return type:

None

Example:
>>> log_to_stdout(LogLevel.DebugLog)
>>> log_alert("Kielbasa!")
Kielbasa!
>>>
log_debug(text: Any, logger: str = '')[source]

log_debug Logs debugging information messages to the console.

Parameters:
  • text (str) – message to print

  • logger (str) –

Return type:

None

Example:
>>> log_to_stdout(LogLevel.DebugLog)
>>> log_debug("Hotdogs!")
Hotdogs!
log_error(text: Any, logger: str = '')[source]

log_error Logs message to console, if run through the GUI it logs with Error icon, focusing the error console.

Parameters:
  • text (str) – message to print

  • logger (str) –

Return type:

None

Example:
>>> log_to_stdout(LogLevel.DebugLog)
>>> log_error("Spanferkel!")
Spanferkel!
>>>
log_info(text: Any, logger: str = '')[source]

log_info Logs general information messages to the console.

Parameters:
  • text (str) – message to print

  • logger (str) –

Return type:

None

Example:
>>> log_info("Saucisson!")
Saucisson!
>>>
log_to_file(min_level: LogLevel, path: str, append: bool = False)[source]

log_to_file redirects minimum log level to a file named path, optionally appending rather than overwriting.

Parameters:
  • min_level (enums.Log_Level) – minimum level to log

  • path (str) – path to log to

  • append (bool) – optional flag for specifying appending. True = append, False = overwrite.

Return type:

None

log_to_stderr(min_level: LogLevel)[source]

log_to_stderr redirects minimum log level to standard error.

Parameters:

min_level (LogLevel) – minimum level to log to

Return type:

None

log_to_stdout(min_level: LogLevel = LogLevel.InfoLog)[source]

log_to_stdout redirects minimum log level to standard out.

Parameters:

min_level (LogLevel) – minimum level to log to

Return type:

None

Example:
>>> log_debug("Hotdogs!")
>>> log_to_stdout(LogLevel.DebugLog)
>>> log_debug("Hotdogs!")
Hotdogs!
>>>
log_warn(text: Any, logger: str = '')[source]

log_warn Logs message to console, if run through the GUI it logs with Warning icon.

Parameters:
  • text (str) – message to print

  • logger (str) –

Return type:

None

Example:
>>> log_to_stdout(LogLevel.DebugLog)
>>> log_warn("Chilidogs!")
Chilidogs!
>>>
redirect_output_to_log()[source]