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
HongzheWang
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 @@
...
@@ -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