1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
@c -*-texinfo-*-
@c This file is part of Guile-SSH Reference Manual.
@c Copyright (C) 2014 Artyom V. Poptsov
@c See the file guile-ssh.texi for copying conditions.
@node Logging
@section Logging
@cindex logging
The @code{(ssh log)} module provides procedures to control the libssh logging
facilities.
@deffn {Scheme Procedure} %default-log-printer priority function message userdata
Default callback for printing log messages to the current error port. The
procedure comments out log messages with ``;;; `` to make it easier to
distinguish libssh traces from Guile-SSH messages in REPL mode.
This callback is set by default.
@end deffn
@deffn {Scheme Procedure} %default-libssh-log-printer priority function message userdata
The procedure makes log messages in the same format as the libssh default log
formatter.
@end deffn
@deffn {Scheme Procedure} current-logging-callback
Return the current logging callback. Returns a procedure or @code{#f} if the
callback is not set.
@end deffn
@deffn {Scheme Procedure} set-logging-callback! callback
Change the current logging callback to @var{callback}. The @var{callback}
must be a procedure that takes four arguments: priority of a log message, a
function name, the message and a custom user data.
Throw @code{guile-ssh-error} on an error. Return value is undefined.
Here is an example of a custom callback which indents each log message
according to its priority:
@lisp
(define (pretty-log-printer priority function message userdata)
(do ((i 1 (1+ i)))
((> i priority))
(display " " (current-error-port)))
(format (current-error-port) "[~a] ~a~%"
(strftime "%Y-%m-%dT%H:%M:%S%z" (localtime (current-time)))
message))
(set-logging-callback! pretty-log-printer)
@end lisp
You can restore the default callback as the follows:
@lisp
(set-logging-callback! %default-log-printer)
@end lisp
@end deffn
@deffn {Scheme Procedure} set-log-userdata! user-data
Set an arbitrary @var{user-data} to be passed to a logging callback.
Throw @code{guile-ssh-error} on an error. Return value is undefined.
By default the user data is set to @code{#f}.
@end deffn
@deffn {Scheme Procedure} get-log-userdata
Get the current user data.
@end deffn
@deffn {Scheme Procedure} format-log priority procedure-name format-string arg ...
Write a formatted message to the libssh log with the given @var{priority}.
Return value is undefined.
Syntax for the @var{format-string} is the same as for @code{format} procedure.
@var{priority} is expected to be a symbol. Acceptable priority levels are:
@table @samp
@item nolog
The message will be printed even if the logging is disabled
@item rare
Rare and noteworthy events
@item protocol
High level protocol information
@item packet
Lower level protocol infomations, packet level
@item functions
Function path
@end table
Note that the procedure uses the provided logging callback directly, bypassing
the libssh logging facilities.
@end deffn
@deffn {Scheme Procedure} set-log-verbosity! verbosity
Set the global log verbosity to a @var{verbosity}. Throw
@code{guile-ssh-error} on error. Return value is undefined.
@var{verbosity} is expected to be one of the following symbols:
@table @samp
@item nolog
The message will be printed even if the logging is disabled
@item rare
Rare and noteworthy events
@item protocol
High level protocol information
@item packet
Lower level protocol infomations, packet level
@item functions
Function path
@end table
@end deffn
@deffn {Scheme Procedure} get-log-verbosity
Get global log verbosity value.
@end deffn
@c Local Variables:
@c TeX-master: "guile-ssh.texi"
@c End:
|