# logopen

Causes Tera Term to start logging.

    logopen <filename> <binary flag> <append flag> [<plain text flag> [<timestamp flag> [<hide dialog flag> [<Include screen buffer>]]]]

## Remarks

Received characters are written to the file <filename>.
When the file does not include \ character, the file is saved at the TeraTerm current directory. If a user want to change the directory, use the changedir macro command.

If <binary flag> is zero, received new-line characters are converted (CR -> CR/CRLF) and escape sequences are stripped out.
If <binary flag> is non-zero, received characters are written without any modifications.

If <append flag> is non-zero and the file <filename> already exists, received characters are appended to it.
If <append flag> is zero and the file <filename> already exists, the file is overwritten.

If <plain text flag> is not 0, ASCII non-printable characters are not written into log.
If <timestamp flag> is not 0, a timestamp is added on top of log.
If <binary flag> is non-zero, <plain text flag> and <timestamp flag> is ignored. The binary log file is available for Replay Log. (version 4.61 or later)

If <hide dialog flag> is not 0, "Log" dialog box is not displayed.

If <Include screen buffer> is not 0, all current screen buffer is written into a log file in first. (version 4.80 or later)

If a log file is successfully opened, the system variable "result" is set to 0. Otherwise, the "result" is set to 1. (version 4.62 or later)

## Example

    connect '/C=1'

    ; get a user name
    getenv 'USERNAME' username
    ; get the date and time
    gettime timestr "%Y%m%d-%H%M%S"

    ; add the user name and the timestamp to the log file name
    sprintf2 filename 'console_%s_%s.log' username timestr

    ; change the current directory
    changedir 'C:\Documents and Settings\yutaka\desktop'

    logopen filename 0 0
    logwrite 'Log start'#13#10
    logwrite '*****************************************************'#13#10
    logclose

    end

    ;
    ; PowerCycle with logging
    ;

    getenv 'USERNAME' username
    gettime timestr "%Y%m%d-%H%M%S"
    getdir mdir
    sprintf2 filename '%s\console_%s_%s.log' mdir username timestr

    logopen filename 0 0

    step = 0
    while 1
      call show_step
      sendln 'echo do something'
      wait '$'
      pause 2
    endwhile

    logclose
    end

    :show_step
    step = step + 1
    gettime timestr
    sprintf2 str '[%d] %s' step timestr
    statusbox str 'counter'
    return

## Reference

logwrite
logclose
statusbox
gettime