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
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
9a69fe9d
Commit
9a69fe9d
authored
Nov 08, 2011
by
Antoine Catton
Committed by
Romain Courteaud
Jan 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplelogger recipe now log in only one file (easier to rotate)
parent
79d801f0
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 @
9a69fe9d
...
@@ -24,31 +24,24 @@
...
@@ -24,31 +24,24 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
import
shutil
import
os
import
sys
import
sys
import
time
import
time
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
log
(
args
):
def
log
(
args
):
directory
,
suffix
=
args
prefix
=
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s:'
)
filename
=
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s'
)
+
suffix
with
open
(
args
[
'filename'
],
'aw'
)
as
logfile
:
with
open
(
os
.
path
.
join
(
directory
,
filename
),
'aw'
)
as
logfile
:
for
line
in
sys
.
stdin
:
shutil
.
copyfileobj
(
sys
.
stdin
,
logfile
)
print
>>
logfile
,
prefix
,
line
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
self
.
logger
.
info
(
"Simple logger installation"
)
wrapper
=
self
.
options
[
'wrapper'
]
binary
=
self
.
options
[
'binary'
]
log
=
self
.
options
[
'log'
]
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."
)
script
=
self
.
createPythonScript
(
wrapper
,
__name__
+
'.log'
,
arguments
=
dict
(
filename
=
log
))
return
[
script
]
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