Skip to content

Commit

Permalink
enable logging
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianhu committed Jan 6, 2017
1 parent 7546cf6 commit 5b801b0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions numcheck.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#!/usr/bin/env python

# import time
from time import gmtime, strftime

# Special precaution: The first character printed must be the result: '1' = yes other = no

import sys
import os

filename = 'numbers.txt'


def log(s):
actime = strftime("%Y-%m-%d %H:%M:%S", gmtime())
with open('calls.log','a') as myFile:
myFile.write("# "+actime+" "+s+"\n")

if 2 != len(sys.argv):
print '0'
print 'Number of arguments:', len(sys.argv), 'arguments.'
Expand Down Expand Up @@ -42,8 +51,10 @@
# print sline must never print in production use - the first char printed counts!
if sys.argv[1].startswith(sline[0]):
print "1 Number found!"
log(str(sys.argv[1]) + " found as " + sline[0])
sys.exit(0)

# at end of execution:
print "0 Number not found!"
log(str(sys.argv[1]) + " not found.")
sys.exit(0)

0 comments on commit 5b801b0

Please sign in to comment.