LogPrint¶
-
class
utilipy.utils.logging.LogPrint(verbose: int = 0, sec_div: str = '-', header: Union[str, None, bool] = None, show_header: bool = True, **kw: Any)[source]¶ Bases:
objectA basic logger wrapper for print.
Initialize LogPrint.
start the file header (just printing)
Methods Summary
close()Close the non-existent file.
newsection([title, div, print])Make new section.
open([verbose, sec_div, header, show_header])Open LogPrint.
Open a logfile to read.
open_to_write([verbose, sec_div, header, …])open_to_write.
print(*text[, start, sep, end])Wrap-function for print.
read_log(filename[, buffering, encoding, …])Read and print out a previous log.
record(*text[, start, sep, end, …])Redirects to write, which goes to print.
report(*msgs[, verbose, print, write, start_at])Report function whose message is determined by
verbose.write(*text[, start, sep, end, …])Print text.
Methods Documentation
-
close()[source]¶ Close the non-existent file.
implemented solely to be overwritten by child classes.
-
newsection(title=None, div=None, print=True) → None[source]¶ Make new section.
- Parameters
- div: str, None (default None)
the divider None -> sec_div from initialization
-
classmethod
open(verbose: int = 0, sec_div: str = '-', header: Union[str, None, bool] = None, show_header: bool = True, **kw: Any) → Any[source]¶ Open LogPrint.
Todo
kw absorbs all extra kwargs to be consistent with LogFile
-
classmethod
open_to_read() → Any[source]¶ Open a logfile to read.
this class uses
open, not a more extensive logger, likeloggingThe arguments filename - opener are all for
open
-
classmethod
open_to_write(verbose: int = 0, sec_div: str = '-', header: Union[str, None, bool] = None, show_header: bool = True, **kw: Any) → Any[source]¶ open_to_write.
Todo
kw absorbs all extra kwargs to be consistent with LogFile
-
print(*text: str, start: str = '', sep: str = ' ', end: str = '\n') → None[source]¶ Wrap-function for print.
- Parameters
- text: str
the text to print
- sep: str (default ‘ ‘)
the separater for print
- end: str (default ‘n’)
the end for print
-
classmethod
read_log(filename: str, buffering: int = - 1, encoding: Optional[Any] = None, errors: Optional[Any] = None, newline: Optional[Any] = None, closefd: bool = True, opener: None = None) → str[source]¶ Read and print out a previous log.
- Parameters
- filename: str
the file name / path at which to save this log
- .. todo::
what should this return?
-
record(*text: str, start: str = '', sep: str = ' ', end: str = '\n', startsection: Union[bool, str] = False, endsection: Union[bool, str] = False) → None[source]¶ Redirects to write, which goes to print.
this is implemented solely for compatibility with LogFile
-
report(*msgs: str, verbose: Optional[int] = None, print: bool = True, write: bool = True, start_at: int = 1, **kw: Any) → None[source]¶ Report function whose message is determined by
verbose.- Parameters
- msgsstr
the verbosity-ordered messages blank messages can be <None>, not only ‘’
- verboseint, optional
which message to record None (default) uses self.verbose (default = 0, unless specified)
- printbool
whether to print, or just record
- writebool
whether to write to logger file write redirects to print in this class
- start_atint
what level of verbosity is the first
msgex: report(‘test’, start_at=3) means ‘test’ is at verbose=3- kw:
kwargs for self.write or self.print
-
write(*text: str, start: str = '', sep: str = ' ', end: str = '\n', startsection: Union[bool, str] = False, endsection: Union[bool, str] = False, print: bool = True) → None[source]¶ Print text.
- Parameters
- text: str
the text to write & print
- start: str (default ‘’)
start to print
- sep: str (default ‘ ‘)
the separater for print
- end: str (default ‘n’)
the end for print
- startsection: bool (default False)
whether to start a new section before writing
- endsection: bool (default False)
-