Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos
Commits
1e7a8842
Commit
1e7a8842
authored
Nov 08, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplelogger recipe now log in only one file (easier to rotate)
parent
06ec72b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
16 deletions
+9
-16
slapos/recipe/simplelogger.py
slapos/recipe/simplelogger.py
+9
-16
No files found.
slapos/recipe/simplelogger.py
View file @
1e7a8842
...
...
@@ -24,31 +24,24 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
shutil
import
os
import
sys
import
time
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
log
(
args
):
directory
,
suffix
=
args
filename
=
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s'
)
+
suffix
with
open
(
os
.
path
.
join
(
directory
,
filename
),
'aw'
)
as
logfile
:
shutil
.
copyfileobj
(
sys
.
stdin
,
logfile
)
prefix
=
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s:'
)
with
open
(
args
[
'filename'
],
'aw'
)
as
logfile
:
for
line
in
sys
.
stdin
:
print
>>
logfile
,
prefix
,
line
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
self
.
logger
.
info
(
"Simple logger installation"
)
binary
=
self
.
options
[
'binary'
]
output
=
self
.
options
[
'output'
]
suffix
=
self
.
options
.
get
(
'suffix'
,
'.log'
)
script
=
self
.
createPythonScript
(
binary
,
'slapos.recipe.simplelogger.log'
,
arguments
=
[
output
,
suffix
])
self
.
logger
.
debug
(
"Logger script created at : %r"
,
script
)
self
.
logger
.
info
(
"Simple logger installed."
)
wrapper
=
self
.
options
[
'wrapper'
]
log
=
self
.
options
[
'log'
]
script
=
self
.
createPythonScript
(
wrapper
,
__name__
+
'.log'
,
arguments
=
dict
(
filename
=
log
))
return
[
script
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment