snapshotlog module

class snapshotlog.LogFilter(mode=0, decode=None)[source]

Bases: object

A Filter for snapshot logs which will both decode log lines and filter them for the requested mode.

Parameters:
CHANGES = 2
ERROR = 1
ERROR_AND_CHANGES = 4
INFORMATION = 3
NO_FILTER = 0
REGEX = {0: None, 1: re.compile('^(?:\\[E\\]|[^\\[])'), None: None, 3: re.compile('^(?:\\[I\\]|[^\\[])'), 4: re.compile('^(?:\\[E\\]|\\[C\\]|[^\\[])'), 2: re.compile('^(?:\\[C\\]|[^\\[])')}
filter(line)[source]

Filter and decode line with predefined mode and decode instance.

Parameters:line (str) – log line read from disk
Returns:decoded line or None if the line was filtered
Return type:str
class snapshotlog.SnapshotLog(cfg, profile=None)[source]

Bases: object

Read and write Snapshot log to “~/.local/share/backintime/takesnapshot_<N>.log”. Where <N> is the profile ID profile.

Parameters:
  • cfg (config.Config) – current config
  • profile (int) – profile that should be used to indentify the log
ALL = 3
CHANGES_AND_ERRORS = 2
ERRORS = 1
NONE = 0
append(msg, level)[source]

Append msg to the log if level is lower than configured log level.

Parameters:
flush()[source]

Force write log to file.

get(mode=None, decode=None, skipLines=0)[source]

Read the log, filter and decode it and yield its lines.

Parameters:
  • mode (int) – Mode used for filtering. Take a look at snapshotlog.LogFilter
  • decode (encfstools.Decode) – instance used for decoding lines or None
  • skipLines (int) – skip n lines before yielding lines. This is used to append only new lines to LogView
Yields:

str – filtered and decoded log lines

new(date)[source]

Create a new log file or - if the last new_snapshot can be continued - add a note to the current log.

Parameters:date (datetime.datetime) – current date