587
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.helium.logger.ant.types;
|
|
18 |
|
|
19 |
import java.io.File;
|
|
20 |
|
628
|
21 |
import org.apache.log4j.Logger;
|
587
|
22 |
import org.apache.tools.ant.types.DataType;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* A 'StageRecord' is a Data type which stores attributes for stage recording/logging.
|
|
26 |
*
|
|
27 |
*
|
|
28 |
* Usage:
|
|
29 |
* <pre>
|
|
30 |
* <hlm:stagerecord id="record.default" defaultoutput="${build.log.dir}/${build.id}_main.ant.log" loglevel="info" append="false"/>
|
|
31 |
*
|
|
32 |
*
|
|
33 |
* <hlm:stagerecord id="record.prep"
|
|
34 |
* stagerefid="preparation"
|
|
35 |
* output="${build.log.dir}/${build.id}_prep.ant.log"
|
|
36 |
* loglevel="info"
|
|
37 |
* append="false"/>
|
|
38 |
*
|
|
39 |
* </pre>
|
|
40 |
*
|
|
41 |
*
|
|
42 |
* @ant.task name="stagerecord" category="Logging"
|
|
43 |
*/
|
|
44 |
public class StageLogging extends DataType {
|
|
45 |
|
|
46 |
private static boolean isAntLoggerRegistered;
|
|
47 |
private String logLevel = "info";
|
|
48 |
private File logFile;
|
|
49 |
private File defaultLogFile;
|
|
50 |
private boolean append = true;
|
|
51 |
private String stageRefId;
|
|
52 |
private Logger log = Logger.getLogger(getClass());
|
|
53 |
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Sets output log file name.
|
|
57 |
* @param output the file to log into
|
|
58 |
* @ant.required
|
|
59 |
*/
|
|
60 |
|
|
61 |
public void setOutput(File output) {
|
|
62 |
this.logFile = output;
|
|
63 |
}
|
|
64 |
|
|
65 |
/**
|
|
66 |
* Returns output log file name.
|
|
67 |
* @return
|
|
68 |
*/
|
|
69 |
|
|
70 |
public File getOutput() {
|
|
71 |
return this.logFile;
|
|
72 |
}
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Sets log level for respective stage.
|
|
76 |
* @param logLevel
|
|
77 |
* @ant.not-required
|
|
78 |
*/
|
|
79 |
|
|
80 |
public void setLogLevel(String logLevel) {
|
|
81 |
this.logLevel = logLevel;
|
|
82 |
}
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Returns log level of respective stage.
|
|
86 |
* @return
|
|
87 |
*/
|
|
88 |
|
|
89 |
public String getLogLevel() {
|
|
90 |
return this.logLevel;
|
|
91 |
}
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Get the name of this StageRefID.
|
|
95 |
*
|
|
96 |
* @return name of the Phase.
|
|
97 |
*/
|
|
98 |
public String getStageRefID() {
|
|
99 |
return this.stageRefId;
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Set the name of the StageRefID.
|
|
104 |
*
|
|
105 |
* @param name
|
|
106 |
* is the name to set.
|
|
107 |
* @ant.required
|
|
108 |
*/
|
|
109 |
public void setStageRefId(String name) {
|
|
110 |
this.stageRefId = name;
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Return default ant log file name.
|
|
115 |
* @return
|
|
116 |
*/
|
|
117 |
public File getDefaultOutput() {
|
|
118 |
return this.defaultLogFile;
|
|
119 |
}
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Set the default ant log name.
|
|
123 |
* @param name
|
|
124 |
* @ant.required
|
|
125 |
*/
|
|
126 |
public void setDefaultOutput(File name) {
|
|
127 |
this.defaultLogFile = name;
|
|
128 |
}
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Set append value.
|
|
132 |
* @param append
|
|
133 |
* @ant.not-required Default is true
|
|
134 |
*/
|
|
135 |
public void setAppend(boolean append) {
|
|
136 |
this.append = append;
|
|
137 |
}
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Return the append value.
|
|
141 |
* @param append
|
|
142 |
* @return
|
|
143 |
*/
|
|
144 |
public boolean getAppend() {
|
|
145 |
return this.append;
|
|
146 |
}
|
|
147 |
|
|
148 |
|
|
149 |
}
|