// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/logger.cpp
// Function: ash::Logger::Logger(ash::Severity)
Logger::Logger(const Severity lvl)
  : ostream(NULL), log(get_target(lvl).c_str(), fstream::out | fstream::app), level(lvl)
{
  char time_now[200];
  time_t t = time(NULL);

  // Get the session_id, if it has already beeen set.
  const char * session_id =
    getenv("ASH_SESSION_ID") ? getenv("ASH_SESSION_ID") : "?";

  // Get the time now.
  struct tm * tmp = localtime(&t);
  if (tmp == NULL) {
    perror("advanced shell history Logger: localtime");
    if (level != FATAL) {
      LOG(FATAL) << "Failed to get localtime on this machine.";  // recurse
    } else {
      log << "SESSION " << session_id << ": " << to_str(level) << ": ";
      return;
    }
  }

  // Get the log date format, if one was specified.
  Config & config = Config::instance();
  string format = config.get_string("LOG_DATE_FMT", "%Y-%m-%d %H:%M:%S %Z: ");
  if (strftime(time_now, sizeof(time_now), format.c_str(), tmp) == 0) {
    if (level != FATAL) {  // avoids infinite recursion.
      LOG(FATAL) << "ASH_CFG_LOG_DATE_FMT is invalid: '" << format << "'";
    } else {
      log << "SESSION " << session_id << ": " << to_str(level) << ": ";
    }
  } else {
    log << time_now << "SESSION " << session_id << ": " << to_str(level)
        << ": ";
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movl %esi, %ebp
movq %rdi, %r15
leaq 0x210(%rdi), %rbx
movq %rbx, %rdi
callq 0x8140
leaq 0x23fe2(%rip), %rsi     # 0x86ca0
movq %r15, %rdi
xorl %edx, %edx
callq 0x8560
leaq 0x23f91(%rip), %rax     # 0x86c60
movq %rax, (%r15)
leaq 0x23faf(%rip), %rax     # 0x86c88
movq %rax, 0x210(%r15)
leaq 0x58(%rsp), %rdi
movl %ebp, %esi
callq 0x6281b
leaq 0x8(%r15), %r14
movq 0x58(%rsp), %rsi
pushq $0x11
popq %rdx
movq %r14, %rdi
callq 0x8430
leaq 0x58(%rsp), %rdi
callq 0x84b0
movl %ebp, 0x208(%r15)
xorl %edi, %edi
callq 0x8350
leaq 0x50(%rsp), %r13
movq %rax, (%r13)
leaq 0xcc01(%rip), %rdi      # 0x6f929
callq 0x84a0
testq %rax, %rax
leaq 0x8bff(%rip), %r12      # 0x6b936
cmovneq %rax, %r12
movq %r13, %rdi
callq 0x8280
movq %rax, %r13
testq %rax, %rax
je 0x62ea0
callq 0x5d6d2
movq %rax, %rbp
leaq 0xd56c(%rip), %rsi      # 0x702ca
leaq 0x58(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x8150
leaq 0xd563(%rip), %rsi      # 0x702d7
leaq 0x30(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x8150
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %rbp, %rsi
callq 0x5d692
leaq 0x30(%rsp), %rdi
callq 0x84b0
leaq 0x58(%rsp), %rdi
callq 0x84b0
movq 0x10(%rsp), %rdx
leaq 0x370(%rsp), %rdi
movl $0xc8, %esi
movq %r13, %rcx
callq 0x82b0
testq %rax, %rax
je 0x62de2
leaq 0x370(%rsp), %rsi
movq %r14, %rdi
callq 0x83a0
movq %rax, %rdi
jmp 0x62def
cmpl $0x4, 0x208(%r15)
movq %r14, %rdi
jne 0x62e5a
leaq 0xd4cb(%rip), %rsi      # 0x702c1
callq 0x83a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x83a0
leaq 0xe9a1(%rip), %rsi      # 0x717ae
movq %rax, %rdi
callq 0x83a0
movq %rax, %r12
movl 0x208(%r15), %edi
callq 0x627fd
movq %r12, %rdi
movq %rax, %rsi
callq 0x83a0
leaq 0xe978(%rip), %rsi      # 0x717ae
movq %rax, %rdi
callq 0x83a0
leaq 0x10(%rsp), %rdi
callq 0x84b0
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x62c92
leaq 0x60(%rsp), %rdi
leaq 0xd47b(%rip), %rsi      # 0x702ee
callq 0x83a0
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x8320
leaq 0xd483(%rip), %rsi      # 0x7030f
movq %rax, %rdi
callq 0x83a0
leaq 0x58(%rsp), %rdi
callq 0x62fc8
jmp 0x62e3e
leaq 0xd3c8(%rip), %rdi      # 0x7026f
callq 0x82d0
cmpl $0x4, 0x208(%r15)
jne 0x62f0d
leaq 0xd404(%rip), %rsi      # 0x702c1
movq %r14, %rdi
callq 0x83a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x83a0
leaq 0xe8d7(%rip), %rsi      # 0x717ae
movq %rax, %rdi
callq 0x83a0
movq %rax, %r12
movl 0x208(%r15), %edi
callq 0x627fd
movq %r12, %rdi
movq %rax, %rsi
callq 0x83a0
leaq 0xe8ae(%rip), %rsi      # 0x717ae
movq %rax, %rdi
callq 0x83a0
jmp 0x62e48
leaq 0x58(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x62c92
leaq 0x60(%rsp), %rdi
leaq 0xd372(%rip), %rsi      # 0x70298
callq 0x83a0
leaq 0x58(%rsp), %rdi
callq 0x62fc8
jmp 0x62d4f
movq %rax, %r15
leaq 0x58(%rsp), %rdi
callq 0x62fc8
jmp 0x62fa8
jmp 0x62f82
jmp 0x62f82
jmp 0x62f9b
movq %rax, %r15
leaq 0x58(%rsp), %rdi
callq 0x62fc8
jmp 0x62f9e
jmp 0x62f82
movq %rax, %r15
leaq 0x30(%rsp), %rdi
callq 0x84b0
jmp 0x62f8a
jmp 0x62f82
movq %rax, %r15
leaq 0x58(%rsp), %rdi
callq 0x84b0
jmp 0x62fb0
jmp 0x62f96
movq %rax, %r15
jmp 0x62fa8
movq %rax, %r15
leaq 0x58(%rsp), %rdi
callq 0x84b0
jmp 0x62fa8
movq %rax, %r15
jmp 0x62fb0
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x84b0
movq %r14, %rdi
callq 0x8590
movq %rbx, %rdi
callq 0x8110
movq %r15, %rdi
callq 0x86f0
movq %rax, %rdi
callq 0x5c505