management.views.loggingΒΆ

Logging setting specific views.

AttributesΒΆ

ClassesΒΆ

IndexView

Index view.

LoggingFilesTableView

View to display all log files in the log directory in a table.

LoggingFilesDetailsView

Log file detail view, allows to view the content of a single log file without download.

LoggingFilesDownloadView

View to download a single log file.

LoggingFilesDownloadMultipleView

View to download multiple log files as a single archive.

FunctionsΒΆ

_secure_log_filename(filename)

Secure a log filename by removing any potentially dangerous characters.

_validate_log_filename(filename)

Validate a log filename and return the resolved path if valid.

language(request)

Handle language Configuration.

Module ContentsΒΆ

management.views.logging._LOG_FILENAME_RE[source]ΒΆ
management.views.logging._CONTROL_CHAR_THRESHOLD = 32[source]ΒΆ
management.views.logging._secure_log_filename(filename)[source]ΒΆ

Secure a log filename by removing any potentially dangerous characters.

Parameters:

filename (str) – The filename to secure

Returns:

The secured filename with dangerous characters removed

Raises:

Http404 – If the filename is invalid

Return type:

str

management.views.logging._validate_log_filename(filename)[source]ΒΆ

Validate a log filename and return the resolved path if valid.

Parameters:

filename (str) – The filename to validate

Returns:

The resolved Path object if valid

Raises:

Http404 – If the filename is invalid or not found

Return type:

pathlib.Path

class management.views.logging.IndexView(**kwargs)[source]ΒΆ

Bases: django.views.generic.base.RedirectView

Index view.

permanent = True[source]ΒΆ
pattern_name = 'management:language'[source]ΒΆ
management.views.logging.language(request)[source]ΒΆ

Handle language Configuration.

Returns: HTTPResponse

Parameters:

request (django.http.HttpRequest)

Return type:

django.http.HttpResponse

class management.views.logging.LoggingFilesTableView(**kwargs)[source]ΒΆ

Bases: trustpoint.page_context.PageContextMixin, trustpoint.logger.LoggerMixin, trustpoint.views.base.SortableTableFromListMixin, django.views.generic.list.ListView

View to display all log files in the log directory in a table.

http_method_names = ('get',)[source]ΒΆ
template_name = 'management/logging/logging_files.html'[source]ΒΆ
context_object_name = 'log_files'[source]ΒΆ
default_sort_param = 'updated_at'[source]ΒΆ
paginate_by = None[source]ΒΆ
page_category = 'management'[source]ΒΆ
page_name = 'logging'[source]ΒΆ
static _get_first_and_last_entry_date(log_file_path)[source]ΒΆ
Parameters:

log_file_path (pathlib.Path)

Return type:

tuple[None | datetime.datetime, None | datetime.datetime]

classmethod _get_log_file_data(log_filename)[source]ΒΆ
Parameters:

log_filename (str)

Return type:

dict[str, str]

get_queryset()[source]ΒΆ

Gets a queryset of all valid Trustpoint log files in the log directory.

Return type:

list[dict[str, str]]

class management.views.logging.LoggingFilesDetailsView(**kwargs)[source]ΒΆ

Bases: trustpoint.page_context.PageContextMixin, trustpoint.logger.LoggerMixin, django.views.generic.TemplateView

Log file detail view, allows to view the content of a single log file without download.

http_method_names = ('get',)[source]ΒΆ
template_name = 'management/logging/logging_files_details.html'[source]ΒΆ
log_directory[source]ΒΆ
page_category = 'settings'[source]ΒΆ
page_name = 'logging'[source]ΒΆ
get_context_data(**kwargs)[source]ΒΆ

Get the context data for the view.

Parameters:

kwargs (Any)

Return type:

dict[str, Any]

class management.views.logging.LoggingFilesDownloadView(**kwargs)[source]ΒΆ

Bases: trustpoint.page_context.PageContextMixin, trustpoint.logger.LoggerMixin, django.views.generic.TemplateView

View to download a single log file.

http_method_names = ('get',)[source]ΒΆ
page_category = 'settings'[source]ΒΆ
page_name = 'logging'[source]ΒΆ
get(*_args, **kwargs)[source]ΒΆ

The HTTP GET method for the view.

Parameters:
  • _args (Any)

  • kwargs (Any)

Return type:

django.http.HttpResponse

class management.views.logging.LoggingFilesDownloadMultipleView(**kwargs)[source]ΒΆ

Bases: trustpoint.page_context.PageContextMixin, trustpoint.logger.LoggerMixin, django.views.generic.View

View to download multiple log files as a single archive.

http_method_names = ('get',)[source]ΒΆ
page_category = 'settings'[source]ΒΆ
page_name = 'logging'[source]ΒΆ
classmethod get(*_args, **kwargs)[source]ΒΆ

The HTTP GET method for the view.

Parameters:
  • _args (Any)

  • kwargs (Any)

Return type:

django.http.HttpResponse