Skip to content

Commit

Permalink
Barachiel v0.3 - Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
nfsec committed Jul 12, 2017
1 parent 28198da commit 68db0a5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions barachiel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# -----------------

import os, re, sys, argparse
import logging, logging.handlers
from getpass import getpass
from fabric.api import *
from fabric.colors import *
Expand Down Expand Up @@ -256,10 +257,18 @@ def sudo_put_command(putthis, failok):
abort("Aborting at user request.")
print(yellow("||| Done.") + "\n")

def logger(logfile):
"""Basic logging and file rotate."""
if os.path.isfile(logfile):
size = os.path.getsize(logfile)
if size >= 104857600:
logging.handlers.RotatingFileHandler(filename=logfile, backupCount=10).doRollover()
logging.basicConfig(filename=logfile, format='%(asctime)s : %(levelname)-9s : %(message)s', level=logging.DEBUG)

def main():
"""Main logic."""
try:
logger('barachiel.log')
args = parse_arguments()
env.skip_bad_hosts = True
env.colorize_errors = True
Expand Down

0 comments on commit 68db0a5

Please sign in to comment.