Log mail messages to eml file
515418
public function log($type, Message $mail): void
	{
		$timestamp = date('Y-m-d H:i:s');
		$type .= '.' . time();
		$file = $this->getLogFile($type, $timestamp);

		if (file_exists($file) && filesize($file)) {
			$file = str_replace(
				static::LOG_EXTENSION,
				'.' . uniqid() . static::LOG_EXTENSION,
				$file
			);
		}

		file_put_contents($file, $mail->generateMessage());
	}
228359
def dump_logs(self):
        
        msg = "log dump: \n"
        if self._transcribe:
            if self._transcribe_queue:
                while not self._transcribe_queue.empty():
                    logs = self._transcribe_queue.get()

                    if isinstance(logs, six.binary_type):
                        logs = logs.decode(encoding='UTF-8', errors="ignore")

                    msg = '{0} {1}'.format(msg, logs)
        else:
            logs = self.client.logs(self.id, stdout=True, stderr=True, stream=False, timestamps=False, tail='all')
            if isinstance(logs, six.binary_type):
                logs = logs.decode(encoding='UTF-8', errors="ignore")

            msg = '{0}{1}'.format(msg, logs)

        logger.error(msg)
968363
def main():
    
    log = logging.getLogger(mod_logger + '.main')
    parser = argparse.ArgumentParser(description='This module allows sending email messages.')
    parser.add_argument('-f', '--file', help='Full path to a plain text file', required=False)
    parser.add_argument('-s', '--sender', help='Email address of the sender', required=False)
    parser.add_argument('-r', '--recipient', help='Email address of the recipient', required=False)
    args = parser.parse_args()

    am = AssetMailer()
    err = None
    if args.file:
        try:
            am.send_text_file(text_file=args.file, sender=args.sender, recipient=args.recipient)
        except AssetMailerError:
            _, ex, trace = sys.exc_info()
            err = '{n}: There was a problem sending email with file {f} from sender {s} to recipient {r}:\n{e}'.format(
                n=ex.__class__.__name__, f=args.file, s=args.sender, r=args.recipient, e=str(ex))
            log.error(err)
    else:
        try:
            am.send_cons3rt_agent_logs()
        except AssetMailerError:
            _, ex, trace = sys.exc_info()
            err = '{n}: There was a problem sending cons3rt agent log files:\n{e}'.format(
                n=ex.__class__.__name__, e=str(ex))
            log.error(err)
    if err is None:
        log.info('Successfully send email')
987951
public static EmailPopulatingBuilder emlToEmailBuilder(@Nonnull final String eml) {
		final MimeMessage mimeMessage = emlToMimeMessage(checkNonEmptyArgument(eml, "eml"), createDummySession());
		return mimeMessageToEmailBuilder(mimeMessage);
	}
294781
def cmd_extract_email(infile, verbose, jsonout):
    

    if verbose:
        logging.basicConfig(level=logging.INFO, format='%(message)s')

    data = infile.read()

    result = []

    result = extract_email(data)

    if jsonout:
        print(json.dumps(result, indent=4))
    else:
        print('\n'.join(result))
835274
def log(message)
      if verbose
        puts "*** #{message}"
      elsif very_verbose
        time = Time.now.strftime('%H:%M:%S %Y-%m-%d')
        puts "** [#{time}] #$$: #{message}"
      end
    end
391849
def _message(self):
        
        filepath = self._record.file_path
        try:
            return load_message(filepath)
        except FileNotFoundError:
            expire_file(filepath)
            empty = email.message.Message()
            empty.set_payload('')
            return empty
647552
def formatMessage(self, record: logging.LogRecord) -> str:
        """"""
        level_color = "0"
        text_color = "0"
        fmt = ""
        if record.levelno <= logging.DEBUG:
            fmt = "\033[0;37m" + logging.BASIC_FORMAT + "\033[0m"
        elif record.levelno <= logging.INFO:
            level_color = "1;36"
            lmsg = record.message.lower()
            if self.GREEN_RE.search(lmsg):
                text_color = "1;32"
        elif record.levelno <= logging.WARNING:
            level_color = "1;33"
        elif record.levelno <= logging.CRITICAL:
            level_color = "1;31"
        if not fmt:
            fmt = "\033[" + level_color + \
                  "m%(levelname)s\033[0m:%(rthread)s:%(name)s:\033[" + text_color + \
                  "m%(message)s\033[0m"
        fmt = _fest + fmt
        record.rthread = reduce_thread_id(record.thread)
        return fmt % record.__dict__
448031
def log_to_file(filename, level=DEBUG):
    """"""
    logger = logging.getLogger("paramiko")
    if len(logger.handlers) > 0:
        return
    logger.setLevel(level)
    f = open(filename, "a")
    handler = logging.StreamHandler(f)
    frm = "%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d"
    frm += " %(name)s: %(message)s"
    handler.setFormatter(logging.Formatter(frm, "%Y%m%d-%H:%M:%S"))
    logger.addHandler(handler)
942333
function logMessage(time, path, message, mode) {
  if (config.logToConsole) {
    console.log(mode ? '['+mode+']' : '', path, message)
  }
  if (dataFile) {
    dataFile.log(time, path, message, mode)
  }
}
805512
def serialize_email_messages(messages: List[EmailMessage]):
    
    return [
        base64.b64encode(zlib.compress(pickle.dumps(m, protocol=4))).decode()
        for m in messages
    ]
509288
def _send_mail(self, receivers_list, subject, body, log_files=None):
        if not receivers_list:
            self.log.info('no valid addresses in requested addresses. Doing nothing')
            return

        self.log.info('sending notification to %s ...', receivers_list)

        """"""
        if log_files:
            msg = MIMEMultipart()
            msg.attach(MIMEText(body))
            for entry in log_files:
                log_mime = MIMEBase('application', "octet-stream")
                log_file = entry[0]  # Output.file
                log_file.seek(0)
                log_mime.set_payload(log_file.read())
                encoders.encode_base64(log_mime)
                log_mime.add_header('Content-Disposition',
                                    'attachment; filename="{}"'.format(entry[1]['filename']))
                msg.attach(log_mime)
        else:
            msg = MIMEText(body)
        msg['Subject'] = subject
        msg['From'] = self.from_address
        msg['To'] = ', '.join([x.strip() for x in receivers_list])

        s = None
        try:
            s = get_smtp_session(self.workflow, self.smtp_fallback)
            s.sendmail(self.from_address, receivers_list, msg.as_string())
        except (socket.gaierror, smtplib.SMTPException):
            self.log.error('Error communicating with SMTP server')
            raise
        finally:
            if s is not None:
                s.quit()
502241
def messageToFile(message):
    
    outFile = StringIO()
    messageGenerator = generator.Generator(outFile, False)
    messageGenerator.flatten(message)
    outFile.seek(0, 0)
    return outFile
920973
function log($message, $type = null, $explicit = false) {
		try {
			$time = date('Y-m-d|H:i:s');
			if ($type === null) {
				$this->appendToFile(date('Y/m/d'), "[$time] $message", $explicit);
			}
			else { // type !== null
				$this->appendToFile($type, "[$time] $message", $explicit);
			}
		}
		catch (\Exception $e) {
			$this->failedLogging($e, $message);
		}
	}
995123
def _log_request(request):
    """"""
    logger.debug("Inbound email received")

    for k, v in list(request.POST.items()):
        logger.debug("- POST['%s']='%s'" % (k, v))

    for n, f in list(request.FILES.items()):
        logger.debug("- FILES['%s']: '%s', %sB", n, f.content_type, f.size)
488290
def message(self):
        
        return '\n'.join(
            [self.from_email, str(self.to), self.subject, self.body])
63033
async def message(self, msg, msg_type=None, use_version=None):
        
        elem_type = msg_type if msg_type is not None else msg.__class__
        version = await self.version(elem_type, None, elem=msg) if use_version is None else use_version

        if self.is_tracked():
            return self.get_tracked()

        if hasattr(elem_type, 'boost_serialize'):
            msg = elem_type() if msg is None else msg
            self.pop_track(use_version is None)
            return await msg.boost_serialize(self, version=version)

        if self.writing:
            self.pop_track(use_version is None)
            return await self.dump_message(msg, msg_type=msg_type)
        else:
            obj = await self.load_message(msg_type, msg=msg)
            return self.track_obj(obj, use_version is None)